I've got a form that does a fair bit of processing. Along the way, things may not work out as expected, and I want to display messages to the user. I've got that working.

However, if things go well, I also want to let the user know. But here's where it gets dicey: I want to go to the custom login page (via wp_redirect()) and display the message there. So, how do I send the message to the login page?

I've dreamed up a pretty involved mechanism, that may work. But I figure this is a fairly standard pattern: WP must already have something in place for this sort of thing.

1 Answer 1


A standard approach is to add a query parameter to the location header (redirect), for example:

$redirect = add_query_arg( 'my-form', 'success', $redirect );
wp_redirect( $redirect );

Then on the redirected-to page, you can conditionally display a message:

<?php if ( filter_input( INPUT_GET, 'my-form' ) === 'success' ) : ?>


<?php endif ?>
  • Thx @TheDeadMedic! Finally decided to serialize the array with all the messages, and put it into the query string with add_query_arg(). (Thx for that: I hadn't seen that one before; or didn't remember it.) Commented Feb 18, 2016 at 19:42
  • If the messages vary based on the input data, that's okay I guess, but I would still suggest my method otherwise. And just make sure to sanitize them when outputting back to the the browser! Commented Feb 18, 2016 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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