Skip to content

Instantly share code, notes, and snippets.

@caseydriscoll
Created August 6, 2014 15:21
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 caseydriscoll/3f56502b6ecfb50ae322 to your computer and use it in GitHub Desktop.
Save caseydriscoll/3f56502b6ecfb50ae322 to your computer and use it in GitHub Desktop.
Tribe: Change Community Events Error Message
// 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