Hi,
I’ve written a basic extension to do some processing following user registration.
I am trying to get a basic extension to work (to begin with). My basic extension is apparently being called when used for member_member_login_start hook, but it gives a 500 error following registration if used for registration hooks.
Here’s my code below, any help is much appreciated.
<?php
class Email_on_reg_ext {
var $settings = array();
var $name = 'Email On Registration';
var $version = '1.0';
var $description = 'Send email on registration';
var $settings_exist = 'n';
var $docs_url = ''; // 'http://ellislab.com/expressionengine/user-guide/';
/**
* Constructor
*
* @param mixed Settings array or empty string if none exist.
*/
function __construct($settings='')
{
$this->EE =& get_instance();
$this->settings = $settings;
}
/**
* Activate Extension
*
* This function enters the extension into the exp_extensions table
*
* @see http://ellislab.com/codeigniter/user-guide/database/index.html for
* more information on the db class.
*
* @return void
*/
function activate_extension()
{
$this->settings = array();
log_message("DEBUG", "Activating Email on reg");
$data = array(
'class' => __CLASS__,
'method' => 'send_email',
'hook' => 'user_register_end',
'settings' => serialize($this->settings),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
);
$this->EE->db->insert('extensions', $data);
}
/**
* Update Extension
*
* This function performs any necessary db updates when the extension
* page is visited
*
* @return mixed void on update / false if none
*/
function update_extension($current = '')
{
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
if ($current < '1.0')
{
// Update to version 1.0
}
$this->EE->db->where('class', __CLASS__);
$this->EE->db->update(
'extensions',
array('version' => $this->version)
);
}
/**
* Disable Extension
*
* This method removes information from the exp_extensions table
*
* @return void
*/
function disable_extension()
{
$this->EE->db->where('class', __CLASS__);
$this->EE->db->delete('extensions');
}
function send_email($data, $id)
{
log_message("debug","Email on reg hook called with data ->".var_export($data, true));
}
// END
}
// END CLASSPacket Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.