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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Notifying users when CiviCRM profile is edited
Pages: [1]

Author Topic: Notifying users when CiviCRM profile is edited  (Read 758 times)

dinkpwns

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 3.4.4
  • CMS version: Drupal 6.22
Notifying users when CiviCRM profile is edited
August 19, 2010, 08:48:08 am
Hello everyone,

I wanted to have an email sent out to a user every time s/he updates their profile. So I looked around in the documentation and found this little gem: http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=33129895

So I went to /sites/all/modules/civicrm/drupal directory and opened the "civicrm.module" file in which I found the " case: 'update' " portion and as the aforementioned documentation page instructs, I copied that snippet and deleted everything that was there (except for the break statement of course) and pasted the snippet I just copied. Then I upload the new edited file and get this error:
Parse error: syntax error, unexpected ':', expecting ']' in /home/%siteroot%/sites/all/modules/civicrm/drupal/civicrm.module on line 424

Line 424 is: $current_value = $array_cell[CRM:'value'];
Now in my defense I am not particularly fluent in PHP but I felt somewhat comfortable making what seemed to be a straightforward change.

What am I missing here? I feel like it should be much easier to apply this change since it was on the wiki with limited documentation but clearly I was wrong :(

Here is what my case: 'update' looks like with the snippet
Code: [Select]
case 'update':
    $account = $user;
    global $user;
    if($account->name==$user->name){ //test to see if the user or admin is updating the record
        $from = variable_get('site_mail', ini_get('sendmail_from'));
        $thefields = null;
        while($array_cell = each($_POST)) {
            $current_value = $array_cell[CRM:'value'];
            $current_key = $array_cell[CRM:'key'];
            if($current_key != 'op' && $current_key != '_qf_default' && $current_key != 'edit'){ //filter out some uneeded fields
                $thefields .= $current_key.": ".$current_value."\n\n";
            }
        }
        $from = variable_get('site_mail', ini_get('sendmail_from'));

        if(!empty($thefields)){
            user_mail($from, 'account modification', t("%u has changed his account information.\n\n%f\n\n%uri",
                         array('%u' => $_POST\[CRM:'first_name'\]." ".$_POST\[CRM:'last_name'\],
                         '%uri' =>url("user/$account->uid/edit", NULL, NULL, TRUE),'%f' => $thefields)),
                         "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
        }
    }
    return civicrm_form_data($edit, $account, $category, false);
    break;

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Notifying users when CiviCRM profile is edited
August 19, 2010, 10:24:09 am
Quote
http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=33129895
I will update the doc.

You don't have to do any code modification, edit the Profile that you exposed in my account and in  Advanced Settings >> just specify email address in  "Notify when profile form is submitted?"

Hth

Kurund
« Last Edit: August 19, 2010, 10:26:00 am by Kurund Jalmi »
Found this reply helpful? Support CiviCRM

dinkpwns

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 3.4.4
  • CMS version: Drupal 6.22
Re: Notifying users when CiviCRM profile is edited
August 19, 2010, 10:36:56 am
Thank you, thank you!

But what if I want to send the email to the user who's profile it is? (as opposed to the same email address every time). Is that possible from the advanced menu you mentioned?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Notifying users when CiviCRM profile is edited
August 19, 2010, 10:41:36 am
Quote
But what if I want to send the email to the user who's profile it is? (as opposed to the same email address every time).
This can be implemented using hooks, check sample hooks in http://svn.civicrm.org/civicrm/branches/v3.2/drupal/civitest.module.sample

Quote
Is that possible from the advanced menu you mentioned?
No

Kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Notifying users when CiviCRM profile is edited

This forum was archived on 2017-11-26.