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?


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. :)

| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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