I added a menu using add_menu_page, which everything works correctly, but when I click this page I want this menu page to open a message editor for a specific message identifier.
As a proof of concept, I tried to redirect javascript redirect to do function like this ...
// Load up the menu page function register_availability_custom_menu_page() { add_menu_page('custom menu title', 'Availability', 'add_users', 'options', 'options_do_page'); } function options_do_page() { echo "<script type=\"text/javascript\">"; echo "window.location = '/whatever_page.php';"; echo "</script>"; }
This approach really works, but I was wondering if this is the best approach, is there a better way to redirect to the page I'm after?
UPDATE
I also tried using wp_redirect with this code ...
add_action( 'admin_menu' , 'admin_menu_new_items' ); function admin_menu_new_items() { wp_redirect( home_url() ); exit; }
This gives me a message about an error already posted, can anyone suggest where I am going wrong?
source share