Support

Account

Home Forums Add-ons Repeater Field Return repeater values by User value Reply To: Return repeater values by User value

  • Hi @fontsnob,

    You can check if the current user is the selected user like this:

    // check if the repeater field has rows of data
    if( have_rows('repeater_field_name') ):
    
     	// loop through the rows of data
        while ( have_rows('repeater_field_name') ) : the_row();
            
            $currentUserID = get_current_user_id();
            $allowedUser = get_sub_field('user_sub_field_name');
            
            if($currentUserID == $allowedUser['ID']){
                the_sub_field('other_sub_field_name');
            }
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;

    Please change the field name according to your field name. You can also debug the user field value by using var_dump(). This page should give you more idea about it: http://www.advancedcustomfields.com/resources/debug/.

    I hope this helps.