Skip to content

Instantly share code, notes, and snippets.

@mAAdhaTTah
Created February 16, 2015 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mAAdhaTTah/7d9ff3e113610cb44bf0 to your computer and use it in GitHub Desktop.
Save mAAdhaTTah/7d9ff3e113610cb44bf0 to your computer and use it in GitHub Desktop.
Using Transients to Display Errors
if ( $errors = get_transient( "my_save_post_errors_{$post_id}_{$user_id}" ) ) {
    foreach( $errors as $error ) { ?>
        <div class="error"><p>
            <?php echo $error; ?>
        </p></div><?php
    }
    delete_transient( "my_save_post_errors_{$post_id}" )
}
if ( ! empty( $errors ) ) {
    set_transient( "my_save_post_errors_{$post_id}_{$user_id}", $errors, 45 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment