Include script files for admin submenu page

You must have created submenu page using add_submenu_page() hook, so you can use wp_enqueue_script inside callback function of add_submenu_page hook. It will load script only on your submenu page. add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug,’callback’); function callback() { //enqueue script } Or if you want to enqueue script in dashboard(all pages) then you can enqueue … Read more

Admin bar is disabled in front

First check admin bar is showing in WP admin. So go to : Users -> YOUR_PROFILE One of the check boxes : “Show Toolbar when viewing site” — make sure that’s checked on . Then if it’s ok add this code to your functions.php : function admin_bar(){ if(is_user_logged_in()){ add_filter( ‘show_admin_bar’, ‘__return_true’ , 1000 ); } … Read more

Redirect admin 403 “Cheatin uh?” admin pages

Sounds like this is what you’re running into. admin_page_access_denied may be the hook you want to use for this. try function dont_show_cheatin_page() { if ( current_user_can( ‘do_not_allow’ ) ) { wp_safe_redirect( admin_url()); // custom redirect instead of Cheatin 403 page exit; } } add_action(‘admin_page_access_denied’, ‘dont_show_cheatin_page’);

Private post hidden from Admin too

By default, WordPress posts set to private are visible to admins, and you can distinguish them on the frontend because they have ‘Private:’ prepended to their title. However, you might have plugins installed that are modifying this behaviour. It could be your capability management plugin, or it could be WooCommerce. The specifics of third-party plugins … Read more

Show global Message in User Profiles with admin only Input field in WordPress Backend

You just need to move the capability check “inwards”: function wpse_230369_quote_of_the_day( $user ) { $quote = esc_attr( get_option( ‘quote_of_the_day’ ) ); ?> <div class=”visible-only-for-admin”> <h3>Quote of the Day Input Field</h3> <table class=”form-table” > <tr> <th><label for=”quote_of_the_day”>Quote of the Day</label></th> <td> <?php if ( current_user_can( ‘administrator’ ) ) : ?> <input type=”text” name=”quote_of_the_day” value=”<?php echo $quote … Read more