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

Wrong variable in extension?

Development and Programming

DEA's avatar
DEA
257 posts
18 years ago
DEA's avatar DEA

Extension hook: member_member_register.

I’m trying to manipulate the text being submitted to a custom member field during member registration. Here’s the function in an extension I’ve written:

function splitmember ($data)
    {
        global $FNS;
        
        if ( isset( $_POST['m_field_id_1'] ) AND $_POST['m_field_id_1'] != '' )
        {
            $ecountry = split(",",$_POST['m_field_id_1']);
            
            $fcountry = trim($ecountry[3]);
            
            $_POST['m_field_id_1'] = $fcountry;
            
            $EXT->end_script    = TRUE;
        }
    }

m_field_id_1 is the name of the custom field in question; however, nothing is happening and no errors reported. I’m wondering if it’s not included in the $data parameter?

       
Derek Jones's avatar
Derek Jones
7,561 posts
18 years ago
Derek Jones's avatar Derek Jones

Well you’re accessing the $_POST array directly, and aren’t using $data at all, but that’s not of consequence. You need to look at the code surrounding the hook to get an understanding of the flow of the application. The member data is already inserted before that hook is called, so altering the $_POST data will have no effect on what happens to the database. Now if instead you were using the ‘member_member_register_start’ hook, then your modification of the $_POST data would have effect, as that hook executes prior to the database insertion of the new member.

       
DEA's avatar
DEA
257 posts
18 years ago
DEA's avatar DEA

Ah, you are correct (well of course you are). Thanks Derek, will change the hook in the extension as directed.

       

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.