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 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

1 Answer 1

up vote 1 down vote accepted

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

Link:

$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' ) );
    exit;
}

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

 
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.