Support

Home Forums Event Espresso Premium Change Attendee #1 to Ticket #1

Change Attendee #1 to Ticket #1

Posted: July 12, 2018 at 2:51 pm

Viewing 4 reply threads


Porter

July 12, 2018 at 2:51 pm

I am trying to change the wording on the registration form from “Attendee #1” to “Ticket #1”

I have used the code suggested in another forum https://gist.github.com/lorenzocaum/4be687c7c9fcb6b779e4#file-new_gist_file-md

But when I add the code below – it causes an issue with the site and the page content does not load. What am I missing?

Below is the code I am using.

//* Adjust the messaging for attendee 1 in registration checkout
function ee_change_messaging_attendee_1_registration_checkout( $content ) {
if (is_page(1346)) {
$content = str_replace( ‘Attendee 1’, ‘Ticket 1’, $content);
return $content;
}
}
add_filter( ‘the_content’, ‘ee_change_messaging_attendee_1_registration_checkout’, 12 );


Tony

  • Support Staff

July 12, 2018 at 3:00 pm

Hi there,

You would be better using something like this:

https://gist.github.com/Pebblo/4c819243acfee1ce36b1

Change line 11:

https://gist.github.com/Pebblo/4c819243acfee1ce36b1#file-functions-php-L11

To 'Attendee %d' => 'Ticket %d',

You can either change line 10 to us 'Attendee Information' => 'Ticket Information', or remove it completely.


Porter

July 12, 2018 at 3:14 pm

Thanks for your quick response – I’ve tried this (code below) but it did not change anything. What have I done wrong?

function mycustom_filter_gettext( $translated, $original, $domain ) {

// This is an array of original strings
// and what they should be replaced with
$strings = array(
‘Attendee Information’ => ‘Ticket Information’,
‘Attendee %d’ => ‘Ticket %d’,
// 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] );
}

return $translated;
}

add_filter( ‘gettext’, ‘mycustom_filter_gettext’, 10, 3 );


Tony

  • Support Staff

July 12, 2018 at 4:13 pm

Hmm, ok I did a little digging and it’s not something you have done, it’s from a change we’ve made to how that string is translated.

You’ll now need to use a different function for the 'Attendee %d' => 'Ticket %d', translation.

Something like this: https://gist.github.com/Pebblo/de0b054ecaeb7d333ca1b823f2b02efa

You can remove the first function if you wish, or use it to translate other strings, it just will not work the string you are currently wanting to change.

(For any translators reading this we switched from __() to _x() so the function above needs to use a different filter for that string.)


Porter

July 12, 2018 at 4:26 pm

Thank you – that’s worked!

Viewing 4 reply threads

The support post ‘Change Attendee #1 to Ticket #1’ 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.

Event Espresso