Support

Account

Home Forums Front-end Issues Match current user id to user relationship field Reply To: Match current user id to user relationship field

  • I am doing this inside a template (archive). I updated my code with WP_Query

       <?php    $user_id = get_current_user_id();
       echo $user_id;?>
        
        <?php $$args = array(
       'post_type' => 'arende',
       'meta_key' => 'utfors_av',
       'post_status'       => 'publish',
       'posts_per_page'    => -1,     
       'order' => 'ASC',
       'meta_query' => array(
           array(
               'key' => 'utfors_av',
               'value' => $user_id, //array
               'compare' => '=',
           )
       )
     );
     $query = new WP_Query($args);;?>

    But this returns the same result as mine did before.