Home Forums Plugin Support WP User Frontend Pro Display all registered Users

This topic is: resolved

Tagged: 

This topic contains 15 replies, has 4 voices, and was last updated by  Richard 5 years ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #4343

    Webfreelance
    Participant
    Post count: 29

    Hi,

    I would like to know how to display all users.
    I have a custom template but need to get specific profile details as well as their avatar.

    Once a user registers it is assigned to a custom user role.

    I am using wp userfrontend pro – purchased.

    #4344

    Tareq Hasan
    Keymaster
    Post count: 2831

    Check here and here. They've got code examples ๐Ÿ™‚

    #4345

    Webfreelance
    Participant
    Post count: 29

    Great thank you. Fast reply ๐Ÿ™‚
    Will this work with getting the field data from a register/profile form in wp userforntend pro?

    #4346

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, you can grab the custom field values by get_user_meta function.

    #4347

    Webfreelance
    Participant
    Post count: 29

    Tareq i tried using their code however it is the same issue i ran into before. You can only query default roles (Contributer, Author..) It doesnt seem to work when you create a custom role.

    #4348

    Tareq Hasan
    Keymaster
    Post count: 2831

    You mean you can't display all users from a certain custom user role? That shouldn't be the case, it should be working fine.

    #4349

    Webfreelance
    Participant
    Post count: 29

    Yes, you can grab the custom field values by get_user_meta function.

    If i used this method will i need to specify each user or will it by default list all data for all user fields that match the meta i'm calling.

    EG if i get_user_meta($name); will it display a list of all the name or will i need to specify the id of the “person”?

    Hope you understand what i'm asking ๐Ÿ™‚

    #4350

    Webfreelance
    Participant
    Post count: 29

    Okay i did see it requires an id (sorry should have read the whole thing..).
    this will be an issue as i need to display all the custom role users dynamically and not manually insert an id.

    #4351

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, you need to pass the user ID.

    [php]
    foreach ($authors as $author) {
    $name = get_user_meta( $author->ID, ‘meta_key', true );

    echo $name;
    }
    [/php]

    #4352

    Webfreelance
    Participant
    Post count: 29

    Ah i see.
    Excuse my lack of php but

    foreach ($authors as $author) {
        $name = get_user_meta( $author->ID, 'meta_key', true );
     
        echo $name;
    }

    What specifies the role? $authors or $author

    #4353

    Tareq Hasan
    Keymaster
    Post count: 2831

    Nothing, I've just gave you an example using the link (display all users) I posted above.

    #4354

    Webfreelance
    Participant
    Post count: 29

    I tried

    // prepare arguments
    $args  = array(
    // search only for Authors role
    'role' => 'Adscene Subscriber',
    // order results by display_name
    'orderby' => 'display_name',
    // check for two meta_values
    'meta_query' => array(
        array(
            // uses compare like WP_Query
            'key' => 'some_user_meta_key',
            'value' => 'some user meta value',
            'compare' => '>'
            ),
        array(
            // by default compare is '='
            'key' => 'some_other_user_meta_key',
            'value' => 'some other meta value',
            ),
        // add more
    ));
    // Create the WP_User_Query object
    $wp_user_query = new WP_User_Query($args);
    // Get the results
    $authors = $wp_user_query->get_results();
    // Check for results
    if (!empty($authors))
    {
        echo '<ul>';
        // loop trough each author
        foreach ($authors as $author)
        {
            // get all the user's data
            $author_info = get_userdata($author->ID);
            echo '<li>'.$author_info->first_name.' '.$author_info->last_name.'</li>';
        }
        echo '</ul>';
    } else {
        echo 'No authors found';
    }

    And it returns ‘No authors found'? I do have users assigned to that role.

    #4355

    Tareq Hasan
    Keymaster
    Post count: 2831

    I thought you understand PHP, thats why I gave you the links. Try this:

    [php]
    <ul>
    <?php
    $blogusers = get_users(‘role=subscriber');
    foreach ($blogusers as $user) {
    echo ‘<li>'.$user->first_name.' ‘.$user->last_name.'</li>';
    }
    ?>
    </ul>
    [/php]

    Check the user role if you are entering it correctly.

    #4373

    Webfreelance
    Participant
    Post count: 29

    Hi Tareq,

    Thank you, managed the rest!

    <?php
    $adsceneusers = get_users('role=adscene-subscriber');
    foreach ($adsceneusers as $adscene);
    $adsceneid = $adscene->ID; {
    echo get_avatar(( $adsceneid ), 80 );
    echo '<li>'.$adscene->first_name.' '.$adscene->last_name.'</li>';
    }
    ?>

    ๐Ÿ™‚

    #14730

    Cory c
    Member
    Post count: 3

    How would I achieve a page with all the avatars like eon basecamp?

Viewing 15 posts - 1 through 15 (of 16 total)

The topic ‘Display all registered Users’ is closed to new replies.