Home › Forums › Backend Issues (wp-admin) › Relationship field user filter › Reply To: Relationship field user filter
// this will effect all relationship fields
// if you only want to effect specific fields
// see https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/
add_filter('acf/fields/relationship/query', 'relationship_only_own_posts', 10, 3);
function relationship_only_own_posts($args, $field, $post_id) {
// update core is something only available to admin
// or super admin on mutlisite
// a lot less code than looking through roles
if (current_user_can('update_core')) {
// not on admin or editor
return $args;
}
$author = get_current_user_id();
$args['author'] = $author;
return $args;
}
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.