views:

36

answers:

1

How do I redirect users to my plugin settings page after they activate my plugin, I tried

register_activation_hook(__FILE__,'activate_myplugin');
function activate_myplugin()
{
//create and populate DB tables
wp_redirect(plugin_setting_url);
}

but it does not work.

+1  A: 

You should be able to do something like this:

register_activation_hook(__FILE__, 'my_plugin_activate');
add_action('admin_init', 'my_plugin_redirect');

function my_plugin_activate()
{
    add_option('my_plugin_do_activation_redirect', true);
}

function my_plugin_redirect()
{
    if (get_option('my_plugin_do_activation_redirect', false)) {
        delete_option('my_plugin_do_activation_redirect');
        wp_redirect(MY_PLUGIN_SETTINGS_URL);
    }
}
Richard M
@Richard thanx... exactly what I wanted..... I love this community...
Pragati Sureka