Remove users access to dashboard

Removing the dashboard: /* Remove the “Dashboard” from the admin menu for non-admin users */ function wpse54085_remove_dashboard () { global $current_user, $menu, $submenu; get_currentuserinfo(); if( ! in_array( ‘administrator’, $current_user->roles ) ) { reset( $menu ); $page = key( $menu ); while( ( __( ‘Dashboard’ ) != $menu[$page][0] ) && next( $menu ) ) { $page … Read more

Add number of members to “Right Now” dashboard widget

So here is the small snippet to show total number of users and all roles with user count. This code should go in the themes functions.php file. The code uses count_user function to fetch the array and show it up on Right Now dashboard screen. function wpse_60487_custom_right_now() { $users = count_users(); echo ‘<table><tbody>’; echo ‘<tr><td … Read more

How can I show different content for different user-levels?

This thread at wordpress.org – http://wordpress.org/support/topic/content-shown-based-on-user-role – suggests using the ‘current_user_can’ function This thread – http://wordpress.org/support/topic/display-a-custom-image-only-if-user-role-is-contributor – suggests you can use it like ‘current_user_can(‘contributor’)’ for different roles. I haven’t tried it but it sounds like it should work.

Using my own user table

$wpdb is a global variable for the database class. In it $wpdb->users points to the name of the users table. As long as it’s the same database, you can use this to change the name of the table but it might create errors if the schema doesn’t match. Another way is to extend the wpdb … Read more

Need to exclude users with no posts from my contributors page

// retrieve latest 5(or all) posts of this user $query = new WP_Query(array( ‘author’ => $author, ‘posts_per_page’ => 5 )); // skip the user if the number of posts is 0 if($query->post_count < 1) continue; // loop through available posts & display the title while($query->have_posts()) : $query->the_post(); the_title(); endwhile; wp_reset_query(); This code should go inside … Read more