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
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']"]
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 ?
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
My issue is resolved now. Thank you!