Passing User Messages to Another Page

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 );
exit;

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

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

    Congrats!

<?php endif ?>

Leave a Comment