3

How do I go about changing out the text on the confirmation page for events so that it says something different? Right now it says "Continue" and we'd like it to say something like "Continue to pay via Paypal". I've been digging through the template files and can't find where I would change that.

1
  • Anyone have an idea besides word replacement? Because we can't just replace "Continue" in all of the places where it says that word. Commented Nov 18, 2017 at 0:54

4 Answers 4

5

You can use the Word Replacement function for this! Here’s a nice tutorial: https://www.cividesk.com/blog/did-you-know-any-word-or-phrase-civicrm-can-be-replaced-another-one

2
  • The issue with that is "Continue" is used in multiple places inside CiviCRM. So it would change it everywhere, not just the confirmation page. Commented Nov 16, 2017 at 23:01
  • Yeah... right; Ok - I've got another idea; will post it. Commented Nov 19, 2017 at 20:21
5
+50

If you're using WordPress, you can write a quick plugin to do this. The following code amends the submit button's text value on the Registration Confirmation form:

add_action( 'civicrm_buildForm', 'my_prefix_alter_form_button', 10, 2 );

/**
 * Amend the Registration Confirmation form submit button value.
 *
 * @param string $formName The name of the form.
 * @param CRM_Core_Form $form The form object.
 */
function my_prefix_alter_form_button( $formName, &$form ) {

    // bail if not the form we want
    if ( $formName != 'CRM_Event_Form_Registration_Confirm' ) return;

    // drill down until we find the submit element and change its value
    foreach( $form->_elements as $element ) {
        if ( isset( $element->_name ) && $element->_name == 'buttons' ) {
            foreach( $element->_elements as $item ) {
                if ( isset( $item->_type ) && $item->_type == 'submit' ) {
                    if ( isset( $item->_attributes ) && $item->_attributes['name'] == '_qf_Confirm_next' ) {
                        $item->_attributes['value'] = __( 'Continue to pay via Paypal', 'my-plugin-slug' );
                    }
                }
            }
        }
    }

}

You can adapt this methodology to work with Drupal too. You'd have to create a module with an appropriately-named function, but the code inside the function should be identical. Here's the code to add to a Drupal module:

/**
 * Amend the button value.
 *
 * @param string $formName The name of the form.
 * @param CRM_Core_Form $form The form object.
 */
function my_module_prefix_civicrm_buildForm( $formName, &$form ) {

    // bail if not the form we want
    if ( $formName != 'CRM_Event_Form_Registration_Confirm' ) return;

    // drill down until we find the submit element and change its value
    foreach( $form->_elements as $element ) {
        if ( isset( $element->_name ) && $element->_name == 'buttons' ) {
            foreach( $element->_elements as $item ) {
                if ( isset( $item->_type ) && $item->_type == 'submit' ) {
                    if ( isset( $item->_attributes ) && $item->_attributes['name'] == '_qf_Confirm_next' ) {
                        $item->_attributes['value'] = t( 'Continue to pay via Paypal' );
                    }
                }
            }
        }
    }

}

You need to substitute my_module_prefix with the actual prefix of your module so that the function receives callbacks from the hook.

5
  • Nice - yes that works [Wordpress or Drupal] - and best of all - it's not a CRM / PHP override; Commented Nov 20, 2017 at 19:39
  • I'm in Drupal. What do I need to do to create a module? I haven't done that before. Commented Nov 21, 2017 at 1:38
  • I've got the module folder, .info file, and a fairly empty .module file created. Commented Nov 21, 2017 at 1:44
  • @JenniSimonis I have updated the answer with the code for your Drupal module. It should go in your .module file. Commented Nov 21, 2017 at 9:29
  • Thanks. It might be a few days before I can test it all out, as I'm working on another issue with CiviEvent, plus Thanksgiving. Commented Nov 21, 2017 at 22:42
3

Try changing the value with Javascript - as in:

document.getElementById("_qf_Confirm_next-top").value="Continue to pay via PayPal";

and something similar (but not the id is different) for the button at the bottom of the page.

Adding JavaScript - since this is a front-facing public Event registration page - I like adding it to the theme js.

1

This might not be a complete solution, but the text for the button is coded in [civicrm.root]/CRM/Event/Form/Registration/Confirm.php at line 305 in version 4.7.22 (and 4.7.27)

$contribButton = ts('Continue to pay via Paypal');
$this->addButtons(array(
    array(
      'type' => 'back',
      'name' => ts('Go Back'),
    ),
    array(
      'type' => 'next',
      'name' => $contribButton,
      'isDefault' => TRUE,
      'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
    ),
  )
);

Replace the first line with

if ($this->_allowWaitlist) {
    $contribButton = ts('Continue');
} else {
    $contribButton = ts('Continue to pay via Paypal');
}

The if statement is needed because the same code is used for confirmation of addition to the wait list.

Caveat is that I haven't checked that there are no effects elsewhere (unlikely as its in something called confirm.php) and that I'm not really a coder so would welcome confirmation that this is right (but it seems to work). But I'm quite proud of getting this far.

If I get the bounty then I can put one on one of my problems!

5
  • 3
    Generaly overriding php is not recommended - it can easily break your site on upgrades Commented Nov 19, 2017 at 18:15
  • Thanks. This is exactly the kind of thing I was looking for. The recommendation for making changes is to take the template files, which this is one, and copy them into a custom template folder, edit them, and use those. I get that generally changing PHP is not recommended, but that is not true when it comes to the template files. Hence why there's a whole system set up for using custom template files. Apparently our copy of confirm.php was older, as it didn't have any of this. I'll have to figure out what changes we made and replicate them. Commented Nov 19, 2017 at 23:26
  • I strongly advise against overriding confirm.php - that’s in /CRM; Commented Nov 20, 2017 at 16:05
  • Just to clarify: confirm.php is not a template file Commented Nov 20, 2017 at 16:07
  • Ah, I was looking at my Confirm.tpl file, not Confirm.php Commented Nov 21, 2017 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.