Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created March 5, 2013 02:25
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 pippinsplugins/e56cf9586b263e46a7f1 to your computer and use it in GitHub Desktop.
Save pippinsplugins/e56cf9586b263e46a7f1 to your computer and use it in GitHub Desktop.
<?php
// function to show errors
function rcp_show_error_messages( $error_id = '' ) {
if( $codes = rcp_errors()->get_error_codes() ) {
do_action( 'rcp_errors_before' );
echo '<div class="rcp_message error">';
// Loop error codes and display errors
foreach( $codes as $code ) {
if( rcp_errors()->get_error_data( $code ) == $error_id ) {
$message = rcp_errors()->get_error_message($code);
do_action( 'rcp_error_before' );
echo '<p class="rcp_error"><span><strong>' . __( 'Error', 'rcp' ) . '</strong>: ' . esc_html( $message ) . '</span></p>';
do_action( 'rcp_error_after' );
}
}
echo '</div>';
do_action( 'rcp_errors_after' );
}
}
// illustration of recording an error
rcp_errors()->add( 'username_unavailable', __( 'Username already taken', 'rcp' ), 'register' );
// illustration of showing just the "register" error messages:
rcp_show_error_messages( 'register' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment