We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Registration redirects to 500 error with new extention

Development and Programming

farhad khan's avatar
farhad khan
7 posts
14 years ago
farhad khan's avatar farhad khan

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 CLASS
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.