just use bitbucket.org, you can have private projects for free (not like on github), works perfecly. My user is beee4life.
I don’t think I found out… I removed the code and started again from scratch…
I would be willing to help you take a look at it, but i’m at work now and I’m only available after 20:00 CET (in about 4 hours)
@tomhawkins yes I was….
My raw rewrite file = http://pastebin.com/CP9BgfR0
The site is not live hence why there are still commented functions and var_dumps in there. I still need to clean it before going live.
There are a few ‘adult’ terms in there, just fyi….
This did it for me as well… I only had Timber activated and a private plugin.
I deactivated both and updated the database. The message was then gone and I reactivated both plugins.
Got it….
$group = get_page_by_title( 'ACF Group name', OBJECT, 'acf-field-group' );
$fields = array();
$fields = acf_get_fields( $group->ID );
// array of excluded field keys
$excluded_fields = array(
'field_584c779a0114c',
'field_584c77690114b',
'field_584c67a239f35'
);
$field_keys = array();
if ( $fields ) {
foreach ( $fields as $field ) {
if ( ! in_array( $field['key'], $excluded_fields ) ) {
$field_keys[] = $field['key'];
}
}
}
// $fields_keys is an array with 'allowed' field keys which can be 'fed' into acf_form
Thanks, will investigate further.
Thanks for the feedback… I understand the idea, but what I’m mainly looking for is to get rid of the manual definition of field id’s since I feel it’s quite error prone. A typo is easily made. I’d like to make that generic/variable.
I was thinking in the line of something like below. The functions might be wrong, but I think the idea is clear
function get_field_ids( $field_group_id ) {
$all_fields = get_field_object();
$field_keys = array();
foreach ( $all_fields as $field ) {
$field_keys[] = $field['key'];
}
return $field_keys;
}
Then you can remove only the fields you don’t need from this array.
It’s easily forgotten to add a new field ID, when you add fields to the field group.
But I understand that it’s not possible (yet).
2 questions following up on this:
1. It has been announced in 2013 already that a ‘back-end’ only option would become available (in this topic). Am I unaware of this option ? If not, would you know the status of this ? Don’t know how your ‘connection’ to @elliot is…
2. Is it (easily) possible to get an array of all field_keys for a certain field group ? And then just remove the keys you don’t want from this array.
I think it’s easier to ‘remove’ (for example) 3 values than to list 20 fields which are allowed. Less fields = less possible errors.
Thanks for the confirmation… Didn’t think it was possible myself, but just checking…
All my (submitted) posts are submitted through a page, which holds the ACF form, which is ‘manipulated’ with an ID to create a new post or update an existing one.
Ah well, my code works so I’ll leave it as is…
Do you know if, what I describe in my OP, is actually possible ?
I have found the culprit…. although I don’t understand quite why it interferes.
This messed it all up:
function redirect_user_to( $redirect_to ) {
global $current_user;
wp_get_current_user();
if ( ! current_user_can( 'manage_options' ) ) {
$redirect_to = wp_redirect( home_url() . '/profile/' );
exit;
}
}
add_action( 'admin_init', 'redirect_user_to', 1 );
The affected roles are copies from the subscriber role which will be extended with 1 or 2 custom capabilities.
My thoughts exactly. I didn’t think it would check on something and certainly not manage_options.
Adding items is not allowed, except by site admins so that won’t be related imho.
Would you have an idea why the aforementioned function kills the dropdowns ??
For those who are interested in using the WP search to search for a value in a meta field, see the code below. Ofcourse adding 1 line to a form needs less code and is thus a lot less error prone.
This is the search form. In my case I want to search for name only, so I added line 4 to uniquely identify this search form (so pre_get_posts won’t be applied to all search queries).
<form class="form form--search" action="" method="post">
<fieldset>
<div>
<input type="hidden" name="name_search" value="1" />
<input type="search" name="s" class="search__input" placeholder="Search for a name" />
<button type="submit" class="button button--submit">Submit</button>
</div>
</fieldset>
</form>
Then add this to functions.php:
function search_filter_for_name( $query ) {
if ( ! is_admin() && $query->is_main_query() && isset( $_POST['name_search'] ) && 1 == $_POST['name_search'] ) {
if ( $query->is_search ) {
// set search string to false, otherwise the search searches in the_content() for this phrase and I want a specific field only
$query->set( 's', false );
// set your desired post type(s)
$query->set( 'post_type', array( 'your_post_type' ) );
// set the meta query for your specific field
$query->set( 'meta_query', array(
'key' => 'field_name',
'value' => $query->query['s']
) );
}
}
}
add_action( 'pre_get_posts', 'search_filter_for_name' );
my initial question still stands
kudos @0000000000
I had no need yet for a taxonomy with more than 1 allowed option but I bet some people will make good use of it 😉
it does… thanks…
I did notice the following…
I entered a bunch of labels : values
For some the label is the same as the value.
After saving the option where the label was equal to the value was shown as a single value in the field groups settings.
Is that something which is done automatically ?
Never noticed this…
No I don’t have any issues (yet)… I started building my site in my native language (Dutch) when I realised I needed to have it in English anyway so I wanted to base it of of English, so had to redo everything 🙂
Which is not a prob since it’s not online yet. Just didn’t wanna do work and then find out it’s wrong.
I’m not claiming my solution is the best. It is what I came up with to ‘overcome’ the serialized problem and I’m happy it works.
I have to look deeper into your solution. It does seem interesting. And I have to admit, I miscalculated. I counted all fields in a group instead of just the checkboxes, which is only 2 or 3…. so that would mean a significant difference in amount of rows.
So if I would have let’s say 30 fields per post (of which at least 15 are obligated) and I have 1000 posts, that means I would have another (15 fields x 1000 posts =) 15000 extra table rows ???
@hube2 I like the idea, but will there be a different row for just each checkbox value (defined in ACF field groups) or will there be an extra row for each checkbox field in each post ?
Not sure if this would work for you but Ultimate WP Query Search Filter has a nice search feature (incl. ajax results).
For checkboxes, you need a work around, as described here.
@rockgeek may I advise you to look into Ultimate WP Query Search Filter ?
That works real nice out of the box, except it has some issues with checkboxes, because UWPQSF expects a single value and not a serialized array, but I found a solution for it, which I posted on my site.
I’m not sure if this would work for you but it’s definitely worth looking into.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.