In WordPress's backend, you can add notifications and errors using HTML that looks like this
<div class="updated error">
<p><?php esc_html_e( 'A bad thing happened!', 'your-text-domain' );?></p>
</div>
You can add these notices using the admin_notices
hook.
add_action( 'admin_notices', function(){
?>
<div class="updated error">
<p><?php esc_html_e( 'A bad thing happened!', 'your-text-domain' );?></p>
</div>
<?php
} );
Does WordPress have a mechanism, or is there a "generally considered good" third party practice, that would allow you to set a "one time" notice? The scenario I'm thinking of is
- User posts a form
- For handling code does stuff, notifies user
- New page loads with notice
- If users reloads or re-navigates to page (back button), message does not display again
Other application frameworks I've used have a session abstraction to handle things like this. I'm curious if WordPress has something similar, or if there's a generally accepted way to do this, or if WordPress plugins Just Don't Do This™.