ADDING CUSTOMIZABLE TEXT TO THE EMAILONAPPROVED PLUGIN WELCOME MESSAGE - Sep 9th, 2015


You can add custom text from a field ('member_welcome'_in a single record editor ('common_information') or add multiple
variables from multiple fields.

The trick is to keep the load viewer library (don't forget to change the server path) and load records calls, and the
variables you create within the function itself.

Then place each variable in a set of braces {} inside the $message=<<< __TEXT__ block


<?php

// UPDATE THESE VALUES
// DON'T UPDATE ANYTHING BELOW THIS LINE

addAction('record_postsave', 'emailOnApproved_sendPassword', null, 4);
//
function emailOnApproved_sendPassword($tableName, $isNewRecord, $oldRecord, $recordNum) {
global
$CURRENT_USER, $SETTINGS;
$fieldname = 'approved';
// error checking
if ($tableName != 'accounts') { return; }
if (!
array_key_exists($fieldname, $CURRENT_USER)) {
die(
__FUNCTION__ .": You must create an accounts fields called '$fieldname'!");
}
// send email
$wasChecked = intval(!$oldRecord[$fieldname] && $_REQUEST[$fieldname]);
$wasUnchecked = intval($oldRecord[$fieldname] && !$_REQUEST[$fieldname]);

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/path_to_server/','','../','../../','../../../');
foreach (
$dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!
function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); };

// load record from 'common_information'
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
$member_welcome = $common_informationRecord['member_welcome'];

$message=<<< __TEXT__
Welcome {$_REQUEST['first_name']} {$_REQUEST['last_name']},

{$member_welcome}



Your membership has been processed successfully and you now have access to the Members Only area of our web site.

Your user name is: {$_REQUEST['username']}
and your temporary login password is: XXXXX

Once you have successfully logged in, you must change your password and can then update your own profile information.

<a href="{$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']}">Click here to login</a>

Best,

The Membership Committee
__TEXT__;


$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .="FROM:". $SETTINGS['adminEmail'];

if (
$wasChecked) {
$errors = mail($_REQUEST['email'],"Your membership has been successfully processed!",$message,$headers);
if (
$errors!=1) { die("Mail Error: $php_errormsg"); }
}

}

?>



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service