Created
November 19, 2015 02:15
-
-
Save mAAdhaTTah/1599752d5a01392d0c11 to your computer and use it in GitHub Desktop.
Using Redirect Args to Display Errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($error) { | |
add_filter('redirect_post_location', function( $location ) use ( $error ) { | |
return add_query_arg( 'my-plugin-error', $error->get_error_message(), $location ); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( array_key_exists( 'my-plugin-error', $_GET) ) { ?> | |
<div class="error"> | |
<p><?php echo 'The post saved with error: ' . esc_html($_GET['my-plugin-error']); ?></p> | |
</div><?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment