Write php code for wordpress to display user count by user role with shortcode
€8-30 EUR
Betalades vid leverans
Hello,
I use wordpress with different user roles. I would like to be able to display via shortcode the user count per role. Can you write the php code that will allow me to use shortcode to display the number of users per definded role?
[user_count role="role_slug"]
I need to use the shortcode in the label of menue items, just in case this is important.
When doing some researche I found some code, but it displays only the count of all users, but maybe it might be helpful for you.
// Function to return user count
function wpb_user_count() {
$usercount = count_users();
$result = $usercount['total_users'];
return $result;
}
// Creating a shortcode to display user count
add_shortcode('user_count', 'wpb_user_count');
With kind regards
Matthias Reiter
Projekt-id: #19053345
About the project
3 frilansare har lagt bud på i genomsnitt €29 för det här jobbet
Hi, I am ready to create shortcode for user count with respect to user roles and assure 100% satisfaction guarantee. Looking forward to your fruitfully response. Regards Muhammad Alyas
Hello. I can help you with writing necessary codes to get number of users with specific role by providing shortcode to be used. We can discuss further details on chat.
Hey, I can try my hands on it, as I guess I have an idea on how to achieve what you want. Let's discuss about it.