• Resolved Dan Bailey

    (@fontosaurus)


    So I’ve got a plugin that I’ve created and on activation, I want to send the user from the plugin to it’s Settings page immediately.

    Here’s the code I’ve got going:

    function dbn_uaa_Plugin_Activated() {
      // some stuff unrelated to the problem goes here
    
      // redirect code follows:
      wp_redirect(admin_url('options-general.php?page=dbn-user-action-settings'));
      exit;
    }
    register_activation_hook(__FILE__, 'dbn_uaa_PluginActivated');

    When the wp_redirect and exit code are in there, none of the function actually functions. Strip it out, the unrelated stuff works fine. But with it there, I attempt to activate the plugin and the resulting URL for the settings page is correct, but I get a “Sorry, you are not allowed to access this page.” error.

    Strip out the redirect code and the plugin activates cleanly. And I can use the sidebar admin menu to navigate to the Settings page, successfully. I’ve compared the URLs generated by the redirect and by the sidebar menu and they are identical.

    I also tried stripping out the redirect code and placing it in class-dbn-uaa-activator.php with the exact same results as trying it with the register_activation_hook code/function shown above.

    What the hell am I missing here?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘wp_redirect to Settings Page’ is closed to new replies.