Contributors missing from author dropdown

My advice is to read the Codex regarding user roles and capabilities. Contributors cannot publish posts. Edit: I am able to successfully add new users with the ‘contributor’ role, and select them from the dropdown as the author of a post, which is what I now realize you’re having issues with. So something is definitely … Read more

Shold I manually add ‘cap’ to admin role ?

A new capability has to be explicitly added to either a role or a user. In your case if you want all administrators to have ‘cap’ capability you will add it to ‘administrator’ role: $role = get_role( ‘administrator’ ); $role->add_cap( ‘cap’ ); If you want a specific administrator only to have ‘cap’ capability then you … Read more

Email notification for editors only

Use get_users() function. Reference function notify_editors( $post_id ) { $post = get_post( $post_id ); // Get all editors $editors = get_users( [ ‘role__in’ => [ ‘editor’] ] ); foreach ( $editors as $editor ) { // Setup email $subject = “Post Published: ” . $post->post_title; $message=” Hi ” . $editor->display_name . ‘, Your post, “‘ … Read more

List total number of users that are authors

count_users() should give you an array of all the required user counts. You can use it like this. $user_counts = count_users(); $authors = $user_counts[‘avail_roles’][‘author’]; //Get the author count $subscribers = $user_counts[‘avail_roles’][‘subscriber’]; //Get the subscriber count echo $authors. ‘ Authors so far’; echo $subscribers. ‘ Subscribers so far’;

Order users by custom user meta

Here’s the solution. Comments included: <?php $results = get_users(‘role=director’); foreach ($results as $result) { // Get data about each user as an object $user = get_userdata($result->ID); // Create a flat array with only the fields we need $directors[$user->ID] = array( ‘dir_order’ => $user->exit_director_order, ‘dir_id’ => $user->ID, ‘dir_name’ => $user->first_name.’ ‘.$user->last_name ); } // Sort sort($directors); … Read more

Remove Ability for Administrators to Delete Administrators

Your question seems to boil down to this I can’t figure out how to check that the $userids in question are an administrators user ID. Try user_can($id,’administrator’) http://codex.wordpress.org/Function_Reference/user_can The Codex has a warning about using role names with the current_user_can function and it is very similar to user_can so I suppose caution is order until … Read more