Category: WordPress Users
Remove WordPress Admin Bar Menu Items
function dashboard_tweaks() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘wp-logo’); $wp_admin_bar->remove_menu(‘about’); $wp_admin_bar->remove_menu(‘wporg’); $wp_admin_bar->remove_menu(‘documentation’); $wp_admin_bar->remove_menu(‘support-forums’); $wp_admin_bar->remove_menu(‘feedback’); $wp_admin_bar->remove_menu(‘view-site’); } add_action( ‘wp_before_admin_bar_render’, ‘dashboard_tweaks’ ); Reference: http://pastebin.com/Wrk0JPxw
Remove Admin Backend Menus for all users, except User #1 (usually the first Admin)
/*———————————————————————————–*/ /* Restrict access /*———————————————————————————–*/ function remove_menus () { global $menu; $user = wp_get_current_user(); if ($user->ID!=1) { // Is not administrator, $restricted = array(__(‘Dashboard’), __(‘Posts’), __(‘Media’), __(‘Links’), __(‘Pages’), __(‘Appearance’), __(‘Tools’), __(‘Users’), __(‘Settings’), __(‘Comments’), __(‘Plugins’)); end ($menu); while (prev($menu)){ $value = explode(‘ ‘,$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);} } } } add_action(‘admin_menu’, ‘remove_menus’);
Remove Admin (User #1) from User list
function your_pre_user_query($user_search) { $user = wp_get_current_user(); if ($user->ID!=1) { global $wpdb; $user_search->query_where = str_replace(‘WHERE 1=1’, “WHERE 1=1 AND {$wpdb->users}.ID<>1”,$user_search->query_where); } } add_action(‘pre_user_query’,’your_pre_user_query’);
Display Specific Content only for logged in users
Tested on: WordPress 3.0.1 function content_only4logged_in($content) { // ALL LOGGED IN USERS if ( is_user_logged_in() && !is_null($content) && !is_feed() ) { return $content; } else { $content = wp_html_excerpt( $content, 80 ); $content .= ‘ …’; $content .= __( ‘Sorry, more of this content is only available for logged users.’, FB_TEXTDOMAIN ); return $content; } […]
Add Custom User Profile Fields
Place the code below into your functions.php file to add custom user profile fields. Edit or add lines as you see fit.Remember not to remove the line: return $contactmethods; otherwise this won’t work. // CUSTOM USER PROFILE FIELDS function my_custom_userfields( $contactmethods ) { // ADD CONTACT CUSTOM FIELDS $contactmethods[‘contact_phone_office’] = ‘Office Phone’; $contactmethods[‘contact_phone_mobile’] = ‘Mobile […]