Support » Plugin: Ultimate Member – User Profile, User Registration, Login & Membership Plugin » Conversion to underscore.js messing up member directory pages

  • kthorjensen

    (@kthorjensen)


    So we used to iterate through members in the member directory with a PHP foreach, like so:

    <?php $i = 0; foreach( um_members(‘users_per_page’) as $member) { $i++; um_fetch_user( $member ); ?>

    This no longer works in 2.1.2 as members-grid.php now uses underscore to iterate like so:

    <# if ( data.length > 0 ) { #>
    <# _.each( data, function( user, key, list ) { #>

    The issue here is that I cannot use um_user to fetch custom fields from user profiles – in this case, I only want to show a user’s first name – like we used to, and there’s no documentation as to how to do so in the new underscore loop. Kind of annoying!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • andytela

    (@andymoonshine)

    Hi

    I came across the same issue, totally messed up our directory page as we had customised the whole front-end
    I have got around it by using good old WP code

    
    $profiles_per_page = 16;
    $members_args      = array(
    	'number'     => $profiles_per_page,
    	'meta_query' => array(
    		array(
    			'key'     => 'role',
    			'value'   => 'member',
    			'compare' => '='
    		),
    		array(
    			'key'     => 'account_status',
    			'value'   => 'approved',
    			'compare' => '='
    		)
    	),
        'orderby'   => 'meta_value',
        'meta_key'  => 'last_name',
    );
    $members_query = new WP_User_Query( $members_args );
    $members_res   = $members_query->get_results();
    $members       = wp_list_pluck( $members_res, 'ID' );
    
    foreach( $members as $member ) {
    ...
    

    Hope this helps you

    Cheers
    Andy

Viewing 1 replies (of 1 total)
  • The topic ‘Conversion to underscore.js messing up member directory pages’ is closed to new replies.