Will McLean is a designer and artist working in the Central Coast of NSW where he lives with his wife and 2 children.

Will is a meticulous developer and favours simplicity and clarity within his code. He can’t stand writing things twice so searches for any way to automate. His experiments can be found in the Exercises section of this site.

Will designs within systems. No project is too small for a design system. He favours the unusual, if not, how can he progress? You can read about his work in the Case Studies section of this site.

Updated: October 26, 2017

This is a Knowledge Base post.

Writing an admin notice after saving a post in WordPress

I recently had to write an alert to a user after the saving of an ACF options page. I did so by using the WordPress admin_notices action.

add_action( 'save_post', 'test_function', 100, 1 );
function test_function( $post_id ) {
  // Save an option for the admin notice
  add_option( 'my_notice_text', 'My Message' );
add_action('admin_notices', 'my_admin_notices');
function my_admin_notices() {
  // If a notice exists then echo it as a notice.
  if ( get_option('my_notice_text') ) {
    echo "

" . get_option( 'my_notice_text' ) . "

"; delete_option('my_notice_text'); } }