How to redirect one admin URL to another when admin page URL has "/admin.php?page=" in it?
The following code (from here, middle section chopped out) allows me to redirect users who land on a certain page in the WP admin to another admin page...
function admin_redirects() {
global $pagenow;
/* Redirect Customizer to Theme options */
if($pagenow == 'customize.php'){
wp_redirect(admin_url('/admin.php?page=theme_options', 'http'), 301);
exit;
}
}
add_action('admin_init', 'admin_redirects');
It works great...for some pages. The problem is I cannot get redirects to work for pages originating with a URL structure such as "admin.php?page=example-options." The example-options string is just a plugin I was working on, but I think you get the idea. I have tried a lot of variations and other things at this point, but nothing is working. Am I missing something?
Topic wp-redirect admin-menu Wordpress
Category Web