Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Register an activation hook and then redirect the user's browser when you're done installing your plugin.

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'));
    // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too.
}
register_activation_hook(__FILE__, 'myplugin_activate');
share|improve this answer
    
Many thanks Zack, i'll give it a go! –  Danny Feb 19 '12 at 18:12
    
Note that "options-general.php?page=myplugin_settings" should reflect your options page request uri. –  Zack Feb 19 '12 at 18:18
    
works perfect however we need to exit; after wp_redirect. See my edit. –  Danny Feb 19 '12 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.