Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

srikanthkosana commented Jul 6, 2017

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