Access to profile variables after form create

Discuss and receive support for the integration of CiviCRM and Joomla!
Locked
meredith
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Sep 07, 2006 3:20 am

Access to profile variables after form create

Post by meredith » Mon Sep 11, 2006 5:24 pm

I want to be able to send an email among other things after a user submits a new profile. I need to have access to the data the user just submitted in order to perform my custom post-processing. I saw the example hook that was written for Drupal that enabled you to send an email after form creation...if i wanted to hack something similar for joomla, where in the code is the appropriate place for me to start playing around?

Thanks!
Meredith

lobo
Joomla! Guru
Joomla! Guru
Posts: 502
Joined: Tue Aug 23, 2005 5:45 am

Re: Access to profile variables after form create

Post by lobo » Mon Sep 11, 2006 7:27 pm

meredith wrote: I want to be able to send an email among other things after a user submits a new profile. I need to have access to the data the user just submitted in order to perform my custom post-processing. I saw the example hook that was written for Drupal that enabled you to send an email after form creation...if i wanted to hack something similar for joomla, where in the code is the appropriate place for me to start playing around?
cool, thanx for the request :) civicrm 1.5 now has preliminary support for joomla hooks :) . U need to define a function called joomla_civicrm_post( ) as defined below (pretty much identical to the drupal sample function) U need to add this function to either the frontend civicrm.php file or the backend admin.civicrm.php file or both. i just tested it and works quite nicely

also i checked the custom file image stuff and that seems to be fixed too. we'll do a release later today / tomorrow

Code: Select all

function joomla_civicrm_post( $op, $objectName, $objectId, &$objectRef ) { 
    // only interested in the profile object and create operation for now 
    if ( $objectName != 'Profile' || ( $op != 'create' && $op != 'edit' ) ) { 
        return; 
    } 
 
    require_once 'CRM/Utils/Mail.php'; 
 
    $fromName  = 'My Org Administrator'; 
    $fromEmail = 'my@my.org'; 
    $from      = CRM_Utils_Mail::encodeAddressHeader( $fromName, $fromEmail ); 
     
    $toEmail   = $objectRef['email-1']; 
    $toName    = "{$objectRef['first_name']} {$objectRef['last_name']}"; 
 
    $params    = print_r( $objectRef, true ); 
    $subject   = "Thank you for supporting My Org"; 
    $message   = " 
Dear $toName: 
 
Thank you for your show of support. The details u signed up with are: 
 
$params 
 
Regards 
 
My Org Team 
"; 
    $cc       = 'cc@my.org'; 
 
    CRM_Utils_Mail::send( $from, 
                          $toName, 
                          $toEmail, 
                          $subject, 
                          $message, 
                          $cc ); 
     
} 
lobo


Locked

Return to “CiviCRM Support”