How to disable users to view Other pages

<?php add_filter(‘pre_get_posts’, ‘my_current_author_posts’); function my_current_author_posts( $query ) { global $pagenow; // Check if you are on the right Admin page, do nothing if not if( ‘edit.php’ != $pagenow || ! isset( $_GET[‘post_type’] ) || ‘page’ != $_GET[‘post_type’] || ! is_admin() ) { return; } // get current user Object $current_user = wp_get_current_user(); // check user … Read more

Show admin bar to editors with Buddypres

Please see https://codex.wordpress.org/Function_Reference/show_admin_bar. With newer version of WordPress you may need to use the following which will leave the Toolbar available in the Dashboard but hide it on all front facing pages. So instead of show_admin_bar(true); you can use add_filter(‘show_admin_bar’, ‘__return_true’);

Admin Bar – Customizer Label Change

You can use the get_node function and admin_bar_menu action. Like so, function edit_customizer_node( $wp_admin_bar ) { $customize = $wp_admin_bar->get_node( ‘customize’ ); if ( $customize ) { $customize->title = __( ‘Customize Theme’, ‘text-domain’ ); $wp_admin_bar->remove_node( ‘customize’ ); $wp_admin_bar->add_node( $customize ); } } add_action( ‘admin_bar_menu’, ‘edit_customizer_node’, 999 ); This can be placed in your theme’s functions.php file. … Read more

Admin Bar Acting Up

Try adding this code to your theme functions.php file: if ( is_user_logged_in() ) { show_admin_bar( true ); } If this doesn’t work, try logging into your site using a new “Incognito” window and see if the Admin Bar shows up on the front end. If it does, you probably need to clear the cookies for … Read more

Admin bar default color scheme for nonregistered/nonlogged users

Follow these steps: Use the following code in your functions.php or your site specific plugin: function set_default_admin_color($user_id) { $args = array( ‘ID’ => $user_id, ‘admin_color’ => ‘coffee’ ); wp_update_user( $args ); } add_action(‘user_register’, ‘set_default_admin_color’); Now, add these lines to force “Coffee” color scheme to be displayed in the admin bar: if ( !current_user_can(‘manage_options’) ) remove_action( … Read more

require/include php file in add_menu()

You can turn on output buffering, include (and evaluate) the PHP file, and save the output (of the evaluated code) in a variable, like so: ob_start(); include ‘docs/row_layouts.php’; $html = ob_get_clean(); Then just use ‘html’ => $html in the meta array when you call the $admin_bar->add_menu(). Or if you don’t need to evaluate any PHP … Read more