Highlight active Admin Menu when added though add_menu_page

add_filter( ‘parent_file’, ‘parent_file_hover’ ); function parent_file_hover( $parent_file ) { global $pagenow; if ( $pagenow == ‘post.php’) $parent_file = “post.php?post={$_REQUEST[‘post’]}&action=edit”; elseif($pagenow == ‘post-new.php’) $parent_file = “post-new.php?post_type={$_REQUEST[‘post_type’]}”; return $parent_file; }

grant multiple roles access to specific admin menu item

You shouldn’t use Roles to handle permissions for your menu page. Instead, use capabilities, and then assign those capabilities to whichever roles should have access. For example, instead of creating a customrole role, use a custom capability like manage_custom_plugin: add_menu_page( ‘Custom-Plugin’, ‘Custom-Plugin’, ‘manage_custom_plugin’, ‘custom-plugin’, ‘init_custom_menu_page’ ); Now, using the Members plugin you can enter manage_custom_plugin … Read more

add_menu_page not show link for custom role

I understand the problem. My customer had purchased a paid plugin that, on the action “admin_menu”, scrolled through the entire global variable $menu and eliminated all the items that were not allowed by their plugin unset( $menu[ $key ] );

Removing menus from users other than the administrator

If you want to exclude menu items by their labels: function hide_menu_items( $items ) { $items_to_exclude = [‘Menu Item 1’, ‘Menu Item 2’]; if ( !current_user_can( ‘manage_options’ ) ) foreach ($items as $key => $item) if ( in_array( $item->title, $items_to_exclude ) ) unset( $items[$key] ); return $items; } add_filter( ‘wp_get_nav_menu_items’, ‘hide_menu_items’, 20 );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)