-
-
Save pippinsplugins/e56cf9586b263e46a7f1 to your computer and use it in GitHub Desktop.
This file contains 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
<?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