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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Standalone form email notification
Pages: [1]

Author Topic: Standalone form email notification  (Read 2475 times)

creativeone

  • Guest
Standalone form email notification
May 24, 2007, 06:17:41 am
Hello - trying again to add a Joomla Hook so that I can have my standalone forms notify the administrator and send message to user.

I added joomla_civicrm_post to the front-end components/com_civicrm/civicrm.php and when I submit the form (http://www.selectivemutismcenter.org/Conference/Conference2.html) it takes me to the joomla login page.  Neither user or admin receives an email.  What am I missing?  Below is the code I  added to the civicrm.php based on the drupal example civitest.module.sample

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;
    }

    civicrm_initialize( true );
    require_once 'CRM/Utils/Mail.php';
 
    $fromName  = 'Selective Mutism Center';
    $fromEmail = 'cindy@selectivemutismcenter.com';
    $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
 
Selctive Mutism Center
";
    $cc       = 'cindy@selectivemutismcenter.com';
 
    CRM_Utils_Mail::send( $from,
                          $toName,
                          $toEmail,
                          $subject,
                          $message,
                          $cc );
     
}

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Standalone form email notification
May 26, 2007, 11:21:58 am

Cindy:

Can u edit your standalone html and change the action link to:

http://www.selectivemutismcenter.com/index.php?option=com_civicrm&task=civicrm/profile/edit&gid=1&reset=1

i.e. the make sure the standalone form points to the frontend component and not the backend component. This should trigger your joomla_civicrm_post function and send the mail etc

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mini_mei

  • Guest
Re: Standalone form email notification
July 13, 2007, 09:09:18 am
Hi!

I would need the same functionality so I tried out creativeone's code
and had a look at the CiviCRM hook specification  (at the drupal example civitest.module.sample too)
as well as at the Using CiviCRM APIs - Code Snippets

where it said that
Quote
...
// Initialization call is required to use CiviCRM APIs.
 civicrm_initialize(true);
...
but when testing it I got the following error:

Fatal error: Call to undefined function civicrm_initialize() in
C:\Programme\xampp\htdocs\marienbruecke\components\com_civicrm\civicrm.php on line 113

I did find a function called _civicrm_initialize() in the civicrm/api/v2/utils.php in the admins component
but I tried it and it wasnt the right one (got another error I can't quote this one now since I'm in a hurry, sorry)

what do I need to include to get it to work/find the missing function?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Standalone form email notification
July 13, 2007, 11:15:43 am

1. this is part of the 1.8 feature set so you might want to wait / test the alpha version of 1.8

2. What happens when you remove that line. I suspect it will work, since civicrm is already initialized in this scenario

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mini_mei

  • Guest
Re: Standalone form email notification
July 17, 2007, 01:25:17 am
Thank you lobo! (and sorry it took me so long to answer)

And yes,  out commenting the call to the function did help - works like a charm now!
I know that version 1.8 has that functionality and I'd love to update but the page is already online and has over 4200 contacsts
and we don't want anything to go wrong. Yes I know just make a DB-copy and so on and I've asked my colleague
if we shouldn't make an update but it was decided that we'll stick with that version so I had to find another solution...

I have another question about the mail:
$params = print_r( $objectRef, true ); is printing out all the forms info and I noticed that when the source
was a dropdown or a check box only a number (for the dropdow the options number and for the check box 1 or 0) is printed.
Is there a way to get the actual value of the selected option?

And I have yet another question (I know, I'm really annoying, sorry) it's about the token {contact.greeting} is there a way I could implement it or is it implemented already in version 1.8?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Standalone form email notification
July 17, 2007, 07:04:31 am

1. No, thats the format and the way html select/checkbox/radio works and how we use it

2. Please check the code and see what changes you need to make to enable contact greeting. There are a fair amount of changes to get this done right.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mini_mei

  • Guest
Re: Standalone form email notification
July 17, 2007, 08:22:46 am
Thanks again lobo!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Standalone form email notification

This forum was archived on 2017-11-26.