WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like to execute a update_options() and stuff and then redirect to another plugins page? Directly after the user clicks a link in a Admin notice.

How would i do that? Ajax? Is that even possible?

share|improve this question
up vote 1 down vote accepted

You could use /wp-admin/admin-post.php.


$url = admin_url( 'admin-post.php?action=somethingunique' );
print "<a href='$url'>Update and redirect</a>";

Then you should register a callback for that action:

add_action( 'admin_post_somethingunique', 'wpse_85825_callback' );

And in that callback you can do what you want:

function wpse_85825_callback()
    if ( current_user_can( 'manage_options' ) )
        update_option( 'my_option', 'some_value' );

    wp_redirect( admin_url( 'users.php' ) );

Note this is just some untested code, take it as a direction, not as final solution. :)

share|improve this answer
Appart from the missing bracket it't working perfectly, i not thaught that this was that easy, seems WP has functions for everything. – James Mitch Feb 14 '13 at 13:09

Your Answer


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.