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
):
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:
add_action( 'admin_init', 'wpse_136058_debug_admin_menu' );
function wpse_136058_debug_admin_menu() {
echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}
This gives (for my setup) the following for the Contact Form 7 plugin menu page:
[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
)
The array element with key 2
is what you are looking for: wpcf7
.