Would this also be possible to set different WordPress configs?
More specifically, I’d like to set the title of a page with a custom form (see http://d.pr/i/VemJ), as well as setting the post_status (e.g. published/draft etc) based on a checkbox.
Do you think this would be possible?
So far I just can’t get it done.. I’m trying to get the field “cursusfoto” (see http://d.pr/i/ibk3) set as the featured image. I already set the return value at the ID (I assume that’s right), see http://d.pr/i/q6nJ.
However, I simply have no clue how to manage this code-wise.. (I’m not a developer).
I just went through http://www.advancedcustomfields.com/resources/filters/acfupdate_value/ and tested various ways of coding, but I don’t think I totally understand..
Where would I need to put the add_post_meta-code you posted in relation to the example code at http://www.advancedcustomfields.com/resources/filters/acfupdate_value/?
Since I’m using it for the post type “course”, I changed the post_type=post into post_type=course.
However, the count still doesn’t work (it still counts everything).
Also, the 1st part of your code (that you last posted) doesn’t work (to show only the authors content) – while an earlier example of you did work – so I used the code below for the first part and added the “Fix post counts” count only.
What I’m currently using (working code).
// So authors can only see their own content (e.g. courses etc)
function posts_for_current_author($query) {
if( !$query->is_admin )
return $query;
$screen = get_current_screen();
if ($screen->base === 'post')
return $query;
if( !current_user_can( 'activate_plugins' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
I haven’t been able to get the count correct, see http://d.pr/i/Ijhs.
Hmm – that count script isn’t working for me.. Anything else I need to change except for the post types (since you targeted “site_listings”).
My bad – your code is working 🙂 Thanks a million!
The only thing that I still need to fix, is the fact that it’s showing incorrect number (See http://d.pr/i/Yw5f).
I know it has nothing to do with ACF: you already helped me with that (and I just purchased my 2nd add-on, btw!). But IF you had any idea on how to get this done, feel free to share it with me and blow my mind regarding your level of support 😉
I replace my code with yours, but this code doesn’t work unfortunately.
Using your code, users are able to see others’ posts.
So it does fix the issue I had (advanced custom fields not showing), but now it doesn’t do the core thing it was supposed to do..
Then how can I retrieve that value, you think?
Woops – I checked the “this solved it”-button, but I’m still struggling with it.
I’m not much of a coder, but I tried various ways of coding and thus far without luck.
Right now I’ve changed it to
function posts_for_current_author($query) {
global $user_level;
if($query->is_admin && $user_level < 5 && get_post_type() != "acf") {
global $user_ID;
$query->set('author', $user_ID);
unset($user_ID);
}
unset($user_level);
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
But unfortunately that doesn’t change a thing.. Any thoughts?
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.