I can’t find any info on this anywhere but i’m sure iv’e seen it done before.
I would like to have a user taken to the settings page for my plugin after install, so either auto-redirected or change the “back to plugins” link to a custom link.
Thanks in advance
SOLVED
function myplugin_activate() {
// TODO: Install your plugin here.
// I don't know of any other redirect function, so this'll have to do.
wp_redirect(admin_url('options-general.php?page=myplugin_settings'));exit;
// You could use a header(sprintf('Location: %s', admin_url(...)); here instead too.
}
register_activation_hook(__FILE__, 'myplugin_activate');
@Zack – Your method works great however you forgot to exit after wp_redirect. (source http://codex.wordpress.org/Function_Reference/wp_redirect)
Many thanks
Register an activation hook and then redirect the user’s browser when you’re done installing your plugin.
I see the question is already answered. But there is a alternate scenario where you might want to redirect to settings page after a theme installed. You can do it very easily using following codes 🙂
You just have to replace the following code
themes.php?page=ot-theme-options
With your own setting page url.
It is farly easy to do and we are using WP redirect function.
Thanks
Sabbir
Well, you also can use another and more elegant solution:
Approved answer is old and produce error inside activation or redirect you to 404 page inside admin. This solution provide you safe redirection with no errors.