Skip to content

Instantly share code, notes, and snippets.

@xnau
Created November 7, 2016 02:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/fc574b45e32f782f141787164063ec86 to your computer and use it in GitHub Desktop.
Save xnau/fc574b45e32f782f141787164063ec86 to your computer and use it in GitHub Desktop.
Notify the user when their record is updated by an admin
<?php
/*
Plugin Name: Participants Database Update Notify
Description: Notifies the user when their record is updated
*/
/*
* before the update is stored, send an email notification to the participant
*/
add_filter( 'pdb-before_submit_update', 'pdb_send_record_update_notification' );
/**
* sends an email notification when a record is updated
*
* @param array $post the submitted record data
* @return array the new record data
*/
function pdb_send_record_update_notification( $post )
{
if ( ! is_admin() || empty( $post['email'] ) ) {
/*
* if we're not in the admin or if there is no email address to send to, do
* nothing and return
*/
return $post;
}
/*
* these three variables will need to be edited for your application
*/
$subject = 'Your record has been updated';
$message = 'Dear [first_name] [last_name],
Your record has been updated.';
$from = 'Your Website <info@yourwebsite.com>';
/*
* put it all together into the configuration array
*/
$config = array(
'to' => $post['email'],
'from' => $from,
'subject' => $subject,
'template' => $message,
);
// send the email
PDb_Template_Email::send( $config, $post );
/*
* return the record data so it can be saved
*/
return $post;
}
@srikanthkosana
Copy link

hi sir,
I am working on a web application written in php & Mysql database and need to send a confirmation email to the user whenever the new event was approved by the admin. I used the above code but it is not working but there is no error showing. Can you please help me out. looking for your reply. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment