Support

Home Forums Event Espresso Premium Change Button Text

Change Button Text

Posted: October 30, 2016 at 1:02 pm


Jsanborn

October 30, 2016 at 1:02 pm

I would like to change the button text that says “Register Now” to “Purchase Tickets”.

If I am going to make changes to a code snippet – where do I add that?

Thank you!


Tony

  • Support Staff

October 31, 2016 at 8:40 am

Hi there,

You will need to add a custom snippet of code to change this, the best place to place the code is within a custom functions plugin, you can follow the steps here to create one:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Then add this example to your custom plugin:

https://gist.github.com/Pebblo/6ca533539b2ed37ed88801825fdd2f2f


Jsanborn

October 31, 2016 at 9:36 pm

This worked beautifully – thank you!


Jsanborn

November 1, 2016 at 10:27 am

Ooops – This changed all the buttons – can it be restricted to only some buttons – I still need the Register Button to say Register Here.


Tony

  • Support Staff

November 1, 2016 at 3:06 pm

I’m sorry but I’m not sure what your mean, can you explain further?

Maybe provide a link to an example of where you would like to change the text and another for where you would like to leave the text as is.


Jsanborn

November 1, 2016 at 10:14 pm

Here is a diagram that shows what I need – https://thetheaterschool.com/button-text-example/

Thank you!


Tony

  • Support Staff

November 2, 2016 at 10:25 am

Both of those sections are just the EE ‘Ticket Selector’ but you are using each section for a different purpose.

The filter I provided changes the text for all instances of the ticket selector as it’s a filter to alter the text and is not currently ‘context aware’, meaning the filter doesn’t know the difference between an event that should output ‘Register Now’ and ‘Purchase Tickets’.

In order to do what you need you’ll need some custom development so that the function know which events need to display what text, are you currently working with a developer?


Jsanborn

November 2, 2016 at 11:47 am

I am the developer – but I am new to WordPress and haven’t mastered all the ins and outs yet, but I can follow directions pretty well!


Josh

  • Support Staff

November 2, 2016 at 12:37 pm

One approach to a solution would be to use a custom field set within the event editor to change the button text. To make this as simple as possible, I should ask, will the majority of events need a button that says “Purchase Tickets” or a button that says “Register Here”?


Jsanborn

November 2, 2016 at 12:44 pm

Register Here will be used the most


Jsanborn

November 2, 2016 at 12:49 pm

What do I use for the URL to tie it in with a different button and how would I keep the wrong button from displaying?


Tony

  • Support Staff

November 2, 2016 at 1:10 pm

So what you need is a function that defaults to the normal button text (Register now) but to check for a custom field within the event and if set use ‘Purchase Tickets’.

Take another look at the gist I provided, I’ve added another example:

https://gist.github.com/Pebblo/6ca533539b2ed37ed88801825fdd2f2f/

The second function checks for a custom field called ‘ee_purchase_tickets’ that you can set within the event itself – http://take.ms/Bg1tw

(Note you will need to create that field, its not added by default)


Jsanborn

November 2, 2016 at 2:07 pm

Okay – I created the new custom field = ee_purchase_tickets and a functions2 php file which I added to my site

Exact Code:
<?php

//Another example that uses a custom field within the event.
//Set ee_purchase_tickets to true within your event to display ‘Purchase Tickets’
//If no value has been set default to the standard button text (Register Now).
function tw_ee_custom_filter_ticket_selector_submit_button_text( $btn_text, $event ) {

$purchase_tickets = $event->get_post_meta( ‘ee_purchase_tickets’, true );

if ( $purchase_tickets ) {
$btn_text = __( ‘Purchase Tickets’, ‘event_espresso’ );
}

return $btn_text;
}
add_filter( ‘FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text’, ‘tw_ee_custom_filter_ticket_selector_submit_button_text’, 10, 2 );

—– Is there another step? I added the new custom field to all of the events. I dont see any changes. https://thetheaterschool.com/rj-one-page/#register


Tony

  • Support Staff

November 2, 2016 at 3:24 pm

The above should work fine, I tested it locally and didn’t run into any issues.

Is there another step? I added the new custom field to all of the events. I dont see any changes.

You only add ee_purchase_tickets to the events that should display ‘Purchase tickets’, have you add that field to the other events? If so that tells the function to display ‘Purchase Tickets’ on all events…

Also, did you remove the previous function?

The first function completely override all events to display ‘Purchase Tickets’ you don’t want that, you could have used the new function in place of the original one I provided and not created a ‘functions2’ file (although I’m not really sure what you mean by that).


Jsanborn

November 2, 2016 at 4:00 pm

Okay – I removed the custom field from the registration events and it is only on the ticket events. I returned functions.php file to the original backup file I had – thus removing the code you gave me. Unfortunately still not working – now both buttons say Register Now. Should I buy a token and will you be able to follow through to help with this?


Josh

  • Support Staff

November 2, 2016 at 4:21 pm

If you buy a support token someone from support staff can get that custom field set up. Please be sure to include FTP credentials when you fill out the redeem a support token form.


Jsanborn

November 2, 2016 at 4:47 pm

I purchased a token – everything can be accessed through the backend of the Avada theme – will they still need ftp creds?


Josh

  • Support Staff

November 2, 2016 at 4:55 pm

Yes we will need FTP creds because we’ll be adding a functions plugin.


Josh

  • Support Staff

November 2, 2016 at 6:23 pm

We received the FTP credentials but I’m afraid that they’re not allowing my FTP client to authenticate. Can you double-check, then resend, and if there’s a Port number we should specify can you include that? Thanks.


Jsanborn

November 2, 2016 at 7:05 pm

I just resubmitted the credentials – port is 21


Tony

  • Support Staff

November 3, 2016 at 9:18 am

Hi there,

I have fixed the above so it is working on your site and responded to your support token via email.

The support post ‘Change Button Text’ 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