1

I have a custom function written to show the name of the contribution page that a PCP is a part of. After some help from the community, I got it working, hooray! Trying to write a hook to add contribution page name to Main.tpl I'm super close

But on my event registration links (not contribution pages, oddly enough) or PCP creation links - I get the following error 'CiviCRM_API3_Exception: "Expected one ContributionPage but found 25"' (I have a total of 25 contribution pages set up so I can see why it says it finds 25 but why it's looking in the first place I'm not sure.

Here is the final code I'm using

function wordpress_civicrm_buildForm($formName, &$form) {
    $config = CRM_Core_Config::singleton();
    if ( $config->userFrameworkFrontend ) {

          $page = civicrm_api3('contribution_page', 'getsingle', array(
            'id' => $form->_id,
            'check_permissions' => FALSE,
            'return' => 'title',
          ));
          $form->assign('cPageName', $page['title']);

    }
}

Ideas?

0

The problem is that your hook is executing unconditionally on every form. To target just the contribution form, the first line inside your function should be if ($formName == 'CRM_Contribute_Form_Contribution_Main') {.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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