Skip Navigation

[Resolved] display list of all users

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have a membership site with 2000+ signed up members with which I need to have to create a list of users and if possible their role.

Solution:

You can try these:

https://toolset.com/forums/topic/display-list-of-all-users/#post-1622297

Relevant Documentation:

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by acts-1224C 4 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1621453

I have a membership site with 2000+ signed up members with which I need to have to create a list of users and if possible their role. I know I can access it in the backend dashboard. However, since I have staff in our office I want my staff who don't have access to the dashboard to access the list, review it for promote or demote role and capabilities.

I am using Types and Blocks to create the view. But I only got as far as displaying the current logged in used. that is not the info I need. I need to display the list of all users and their role. I have created forms for demote and promote to be used with the edit link, but I need ALL USERS to display for the revision department and control.

Thanks

#1622297
Any-role.JPG

Hello,

You can try these:
1) Dashboard-> Toolset-> Settings-> General,
in section "Editing experience", enable option: Show both the legacy and Blocks interface and let me choose which to use for each item I build

2) Dashboard-> Toolset-> Views
create a user view:
Query "Any role" users, see screenshot Any-role.JPG
Then you will be able to get all users of your website

To display user's rule, it needs to create a custom shortcode, for example:

function get_users_role_func( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'user_id' => '',
        ),
        $atts
    );
 
    $user_info = get_userdata($atts['user_id']);
 
          return implode(', ', $user_info->roles);
 
 
}
add_shortcode( 'get_users_role', 'get_users_role_func' );

Use above shortcode in view's loop, like this:
[get_users_role user_id="[wpv-user field='ID']"]

#1627187

Thanks Luo, so let me see if I understood. I should save the snippet code in the functions file and use this short code [get_users_role user_id="[wpv-user field='ID']"] in the loop? or have the function completely inside the loop ?

#1628279

Yes, you are right:

save the snippet code in the functions file and use this short code [get_users_role user_id="[wpv-user field='ID']"] in the loop

#1630869

My issue is resolved now. Thank you!