Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created January 10, 2020 12:14
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 Pebblo/e0b88c12988f1d12c16692e4d4554bf0 to your computer and use it in GitHub Desktop.
Save Pebblo/e0b88c12988f1d12c16692e4d4554bf0 to your computer and use it in GitHub Desktop.
Example of how to change the User registration check on SPCO.
<?php //Please do not include an opening PHP tag if you already have one.
function tw_ee_mycustom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'The event you have selected requires logging in before you can register. You can %sregister for an account here%s if you don\'t have a login.' =>
'Custom The event you have selected requires logging in before you can register. You can %sregister for an account here%s if you don\'t have a login.',
);
// See if the current string is in the $strings array
// If so, replace its translation
if ( isset( $strings[$original] ) ) {
// This accomplishes the same thing as __()
// but without running it through the filter again
$translations = get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'tw_ee_mycustom_filter_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment