How to check if a user is in a specific role?

If you only need this for current user current_user_can() accepts both roles and capabilities. UPDATE: Passing a role name to current_user_can() is no longer guaranteed to work correctly (see #22624). Instead, you may wish to check user role: $user = wp_get_current_user(); if ( in_array( ‘author’, (array) $user->roles ) ) { //The user has the “author” … Read more

Query pages created by deleted users

WordPress gives you a few options on the Dashboard when you delete a user. As far as I am aware the options are: Delete the user but keep their name / credit on created content Delete the user and attribute their content to another user Delete the user AND delete their content Unless there were … Read more

Storing huge number of users in wordpress

In this pursuit, since the students could be thousands in a school, would it be a good practice to have so many entries in the wp_users table by creating a separate user_role : students’? A separate user role will make no difference to site performance or scalability. Or should I create a separate table to … Read more