I read that you have to match the string exactly, otherwise it wont get replaced. I then found the string in getMembersOnlyTicketMessage in the EED_WP_Users_Ticket_Selector.module file, and copied and pasted directly from there. I’ve also tried to increase the priority on the hook, but it still doesn’t replace the string.
The code that I have:
function mycustom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$actual_link = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}/{$_SERVER['REQUEST_URI']}";
$strings = array(
"The %1$s%2$s%3$s%4$s is available to members only. %5$s" => "The %1$s%2$s%3$s%4$s <br/> is only available to registered users, please login for discount prices on events. Log in %5$s"
// Add some more strings here
);
// 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] );
}
The above function throws an undefined variable notice each time it is run:
Notice: Undefined variable: s
Which is happening because the string is wrapped using double-quotes so PHP is trying to parse any variables within it.
You could switch out the string and using single queotes etc, however, there is a filter available to change the string which will parse faster than using gettext.
Build out your own string passed to sprintf and return the value.
Viewing 1 reply thread
The support post ‘Gettext not replacing the ticket details for non-logged-in users.’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.