Support

Account

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;
      }