Support

Account

Home Forums Add-ons Repeater Field Passing user_id var from user profile page to relationship/query/ filter

Unread

Passing user_id var from user profile page to relationship/query/ filter

  • Hi

    I’m trying to grab the user_id from /wp_admin/user_edit.php?user_id=1234 and pass it to the relation/query/name=course filter so only courses by that user (they are the course author) appears in the pickable list displayed on it. User pages will be editable by any admin user so it can’t be via the current user id.

    Essentially I need to substitute 1234 for $_GET[‘user_id’] or via another way but it does not pass it through. I can’t get the author id from $post_id as the user profile isn’t a post

    add_filter('acf/fields/relationship/query/name=course', 'my_acf_fields_relationship_query', 10, 3);
    function my_acf_fields_relationship_query( $args, $field, $post_id ) {
      if ( IS_PROFILE_PAGE ):  
        $args['author'] = 1234;	
        return $args;
      endif;
    }

    Any help would be much appreciated!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.