Created
August 6, 2014 15:21
-
-
Save caseydriscoll/3f56502b6ecfb50ae322 to your computer and use it in GitHub Desktop.
Tribe: Change Community Events Error Message
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
// Add to your active theme's functions.php | |
add_filter( 'tribe_community_events_form_errors', 'ce_custom_error_msg' ); | |
function ce_custom_error_msg( $errors ) { | |
// Don't filter if it is an 'update' or other type of message | |
if ( $errors[0]['type'] != 'error' ) return $errors; | |
$existing_errors = ''; | |
$type = 'error'; | |
if ( is_array( $errors ) ) { | |
$existing_errors = $errors[0]['message']; | |
$type = $errors[0]['type']; | |
} | |
// Set overall message by appending a heading to the front | |
$errors[0] = array( | |
'type' => $type, | |
'message' => '<h5>You did not do something critical</h5>' . $existing_errors | |
); | |
// User str_replace to choose a specific message to change | |
$errors[0]['message'] = str_replace( 'Event Title is required', 'You need to add a title', $errors[0]['message'] ); | |
return $errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment