You need to use the right hooks (which are not always the same as the URLs/slugs), and it doesn’t hurt to use a hook that runs later (e.g., admin_init):
1 2 3 4 5 6 7 | add_action( 'admin_init', 'wpse_136058_remove_menu_pages' ); function wpse_136058_remove_menu_pages() { remove_menu_page( 'edit.php?post_type=acf' ); remove_menu_page( 'wpcf7' ); } |
You can use the following to debug:
1 2 3 4 5 | add_action( 'admin_init', 'wpse_136058_debug_admin_menu' ); function wpse_136058_debug_admin_menu() { echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . ' |
’;
}
This gives (for my setup) the following for the Contact Form 7 plugin menu page:
1 2 3 4 5 6 7 8 9 10 | [27] => Array ( [0] => Formular [1] => wpcf7_read_contact_forms [2] => wpcf7 [3] => Contact Form 7 [4] => menu-top menu-icon-generic toplevel_page_wpcf7 menu-top-last [5] => toplevel_page_wpcf7 [6] => none ) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.