This topic contains 15 reply and 4 voices, and was last updated by Richard 5 years, 8 months ago
Viewing 15 Posts - 1 through 15 (of 15 total)
Author Posts
May 30, 2013 at 4:04 pm 4343
Richard 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.
May 30, 2013 at 4:08 pm 4344
Tareq Hasan Tareq Hasan

Check here and here. They’ve got code examples 🙂

May 30, 2013 at 4:10 pm 4345
Webfreelance Webfreelance

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

May 30, 2013 at 4:12 pm 4346
Tareq Hasan Tareq Hasan

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

May 30, 2013 at 4:15 pm 4347
Webfreelance Webfreelance

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.

May 30, 2013 at 4:17 pm 4348
Tareq Hasan Tareq Hasan

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.

May 30, 2013 at 4:20 pm 4349
Webfreelance Webfreelance

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 🙂

May 30, 2013 at 4:23 pm 4350
Webfreelance Webfreelance

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.

May 30, 2013 at 4:25 pm 4351
Tareq Hasan Tareq Hasan

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]

May 30, 2013 at 4:30 pm 4352
Webfreelance Webfreelance

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

May 30, 2013 at 4:35 pm 4353
Tareq Hasan Tareq Hasan

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

May 30, 2013 at 4:42 pm 4354
Webfreelance Webfreelance

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.

May 30, 2013 at 5:23 pm 4355
Tareq Hasan Tareq Hasan

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.

May 31, 2013 at 7:17 am 4373
Webfreelance Webfreelance

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>';
}
?>

🙂

January 24, 2014 at 3:46 am 14730
Cory c Cory c

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

February 6, 2014 at 9:30 am 15107
Richard Richard

Hello Everyone,

Can anyone tell me how to limit the number of user profiles on the dashboard? I have more than 20 members for each project and the user avatars have completely overrun the project info, making my dashboard area rendered useless and nothing more than a large number of profile pictures.

Any advice would be greatly appreciated. I’ve searched this forum but don’t see any gore issue related to this and why I chose to post here as it’s loosely related.

I thank you in advance.

Viewing 15 Posts - 1 through 15 (of 15 total)