CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Problems Overriding Params in BuildForm
Pages: [1]

Author Topic: Problems Overriding Params in BuildForm  (Read 326 times)

Dan C

  • I post frequently
  • ***
  • Posts: 179
  • Karma: 17
  • CiviCRM version: All
  • CMS version: Joomla 2.5 and 3.X, Drupal 7, Wordpress 3.7 and up
  • MySQL version: 5.1.7 and up
  • PHP version: 5.3.5 and up
Problems Overriding Params in BuildForm
June 07, 2014, 07:18:38 am
I have a client who wants to set the No Bulk Mail flag to Yes by default for all new contacts, without affecting any existing contacts.  I was able to do this through the BuildForm hook for contributions on the Confirmation page without a problem but am not able to do so on Event Registrations.  For some reason any changes I make to the _params section of the form are not carrying over from the Confirmation page to the Thank You page.  My code will reset the is_opt_out flag on the confirmation page just fine, I printed the _params array at the end of BuildForm just to be sure.  But then when I print it out at the end of BuildForm on the Thank You page, any changes I make (I tried changing the primary-Email as well) aren't reflected and the record entered into Civi has the originally entered values.

My Code is:
Code: [Select]
if($formName=="CRM_Event_Form_Registration_Confirm")
{
$params = $form->getVar( '_params');
$contacts = civicrm_api('Contact', 'Get', array(
  'version' => 3,
  'email' => $params[0]['email-Primary'],
));
if($contacts['count']==0)
{
$params2 = $form->getVar( '_params');
$params2[0]['is_opt_out']=1;
$params2[0]['email-Primary']='did@dd.co';
$form->setVar( '_params', $params2 );
}
}

I have tested this both on an existing Joomla 2.5.19/Civi 4.3.7 install as well as a completely clean Joomla 2.5.20/Civi 4.4.3 install.  I don't know if I'm hitting some bug or if there is some major difference in interacting with the _params values during Event Registrations that I'm missing.  Any help would be appreciated.
CrusonWeb - Web Development, Implementation, and Support.  Specializing in CiviCRM and Joomla (although also knowledgable in Wordpress and Drupal as well).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Problems Overriding Params in BuildForm

This forum was archived on 2017-11-26.