thanks, now I understand the concept of recall.
I had not thought because I usually use the foreach statement to retrieve reperater.
correct as always,
Thanks!
I was wondering,
you can set the filter applies only to users and not admins or moderators?
I tried to use this code to differentiate between users and admin, but it is as if nothing is filtering.
if ( ! is_admin() ) {
// modify the order
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$args['author']=$user_id;
$args['authors']=$user_id;
$args['post_type']='stand';
return $args;
}
else { $args['post_type']='stand'; return $args; }
There is solution?
Thanks
Thank you, can not imagine what relief dates when you solve a problem that blocks an entire project like mine.
To put chronicle the complete function for this specific use.
Result on the URL of site:
my url for archive page: http://mydomain.com/newstand/?newstand_selettore_stand=3640
The function:
function my_pre_get_posts_newstand( $query ) {
// validate
if( is_admin() ) { return; }
if( !$query->is_main_query() ) { return; }
// get original meta query
$meta_query = $query->get('meta_query');
// allow the url to alter the query
// eg: http://www.website.com/events?location=melbourne
// eg: http://www.website.com/events?location=sydney
// eg http://www.luccafan/newstand/?newstand_selettore_stand=3640
if( !empty($_GET['newstand_selettore_stand']) ){
$newstand_selettore_stand = explode(',', $_GET['newstand_selettore_stand']);
if( !empty($newstand_selettore_stand) ) {
foreach( $newstand_selettore_stand as $id ) {
$meta_query[] = array(
'key' => 'newstand_selettore_stand',
'value' => $id,
'compare' => 'LIKE',
);
}
}
}// end of !empty($_GET['newstand_selettore_stand'])
// update the meta query args
$query->set('meta_query', $meta_query);
// always return
return;
}
add_action('pre_get_posts', 'my_pre_get_posts_newstand');
here’s what I had missed.
Yes, now it works properly!
thanks so much
my custom post is : ‘stand’
function my_post_object_query( $args, $field, $post ) {
// modify the order
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$args['author']=$user_id;
$args['authors']=$user_id;
$args['post_type']='stand';
return $args;
}
// filter for every field
add_filter('acf/fields/post_object/query/name=stand', 'my_post_object_query', 10, 3);
excuse me,
I need the same function.
or at least I think it is the same:
I need that in the “post_object” seen in the admin side, you see a list of our posts in a specific custom post, obviously without seeing those of others.
I copied the code and I replaced the custom post with my “franchises” -> “stand”
But by testing with user semplicesi continues to see the full list.
What I’m missing?
Ok with 5.0.6 it all ok. thanks
boh … expect some developers tell us something.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.