<?php
/**
* @copyright xxxxxx.
*/
// make sure we are not being called directly
defined('APP_DIR') or exit();
/**
* meta
*/
function xxSignupNotify_meta()
{
$_tmp = array(
'name' => 'Signup Notify',
'url' => 'signupnotify',
'version' => '1.0.0',
'developer' => 'whoever developed this, ©' . strftime('%Y'),
'description' => 'Send out an email to the system admin when a new user signs up.',
'category' => 'communication'
);
return $_tmp;
}
/**
* init
*/
function xxSignupNotify_init()
{
return true;
}
/**
* init
*/
function xxSignupNotify_init()
{
//register event listeners
jrCore_register_event_listener('jrUser','signup_activated','xxSignupNotify_signup_activated_listener');
return true;
}
/**
* Listens for when new users activate their account so it can
* activate the associated user profile
* @param $_data array Array of information from trigger
* @param $_user array Current user
* @param $_conf array Global Config
* @param $_args array additional parameters passed in by trigger caller
* @param $event string Triggered Event name
* @return array
*/
function jrProfile_signup_activated_listener($_data,$_user,$_conf,$_args,$event)
{
//....
/**
* Listens for when new users activate their account so it can
* send a note to the admin users
* @param $_data array Array of information from trigger
* @param $_user array Current user
* @param $_conf array Global Config
* @param $_args array additional parameters passed in by trigger caller
* @param $event string Triggered Event name
* @return array
*/
function xxSignupNotify_signup_activated_listener($_data,$_user,$_conf,$_args,$event)
{
return $_data;
}
function xxSignupNotify_signup_activated_listener($_data, $_user, $_conf, $_args, $event)
{
//add in fdebug to see what we have in our incoming data
//set each of the variables into an array
$debug = array(
'what' => 'We are trying to see what info we have to work with when xxSignupNotify_signup_activated_listener() fires ',
'$_data' => $_data,
'$_user' => $_user,
'$_conf' => $_conf,
'$_args' => $_args,
'$event' => $event
);
fdebug($debug);
return $_data;
}
Array
(
[what] => We are trying to see what info we have to work with when xxSignupNotify_signup_activated_listener() fires
[$_data] => Array
(
[user_name] => eight
... lots of keys ...
[profile_updated] => 1375516290
)
[$_user] => Array
(
[is_logged_in] => yes
... lots of keys ...
[user_active_profile_id] => 1
)
[$_conf] => Array
(
[jrCore_base_url] => http://jr500.iixxii.cc
... lots of keys ...
[_] =>
)
[$_args] => Array
(
[module] => jrUser
)
[$event] => signup_activated
)
function xxSignupNotify_signup_activated_listener($_data, $_user, $_conf, $_args, $event)
{
//email is set in the admin panel under 'Email Support' -> "From Email Address"
$email = $_conf['jrMailer_from_email'];
// Send system admin an email
$_rp = array(
'system_name' => $_conf['jrCore_system_name'],
'jamroom_url' => $_conf['jrCore_base_url'],
'user_name' => $_data['user_name'],
'user_email' => $_data['user_email'],
'profile_name' => $_data['profile_name'],
'profile_url' => $_data['profile_url']
);
list($sub, $msg) = jrCore_parse_email_templates('xxSignupNotify', 'new_user', $_rp);
if (isset($email) && jrCore_checktype($email, 'email')) {
jrCore_send_email($email, $sub, $msg);
}
return $_data;
}
[{$system_name}] A new user has signed up! {$profile_name}
Hi Admin,
A new user has signed up to your system {$system_name}!
Their details are:
user name: {$user_name}
user email: {$user_email}
profile name: {$profile_name}
profile url: <a href="{$jamroom_url}/{$profile_url}">{$jamroom_url}/{$profile_url}</a>