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

extension created: group assignment after self-activation - stuck/need help!

Development and Programming

avroo's avatar
avroo
164 posts
17 years ago
avroo's avatar avroo

Goal: assign a member to a group, based upon the value of a custom registration field. Hook: member_register_validate_members

Ok, so I created an extension based upon different forum threads. I attached the file.

Situation: I register a testuser (frontend) I receive the activation email I click the link which brings me to “http://site.com/index.php?ACT=8&id=9DcfuWIsUE”

The following lines of code should give me the member_id, so I can get the value of my custom field (m_field_id_3 from exp_member_data).

$authcode = $_GET['id']; //get te authcode from URL
$resultaat = $DB->query("select member_id from exp_members where authcode = $authcode"); //get member_id
$current_member_id = ($resultaat->row['member_id']);

Problem: The query doesn’t seem to do anything. No value is returned, even if I fill in the authcode by hand (when I run it on the mysql shell it returns the member_id as it should be, so the record is there!)

Hope anybody can help me out with this. Thanks!

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Not 100% sure you can just use the GET variable like that in EE.

Try something like this:

global $IN;

$authcode = $IN->GBL('id'); //get te authcode from URL
$resultaat = $DB->query("select member_id from exp_members where authcode = '".$DB->escape_str($authcode)."'"); //get member_id
$current_member_id = ($resultaat->row['member_id']);
       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

Aha, yes that old chestnut… If you inspect the code around where this hook is implemented you will see that the authcode is emptied just before the hook is called. I have an FR for moving that single line of code to below the extension call, please add your voice 😊. (A workaround is to just move that line of code to below the extension call)

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Good catch the_butcher!

       
avroo's avatar
avroo
164 posts
17 years ago
avroo's avatar avroo

the GET variable isn’t the problem, works fine when I grab it from the URL and echo it. The problem is the query: doesn’t seem to return anything, even if I fill in the authcode by hand like this:

$resultaat = $DB->query("select member_id from exp_members where authcode = 'CODE_HERE'"); //get member_id
echo "test ".$current_member_id = ($resultaat->row['member_id']);

behind the echo there’s nothing…and this query really should return the member_id

edit Ah sorry, now I get it. The auth code is emptied from the database just before the hook..doh..that is what you meant.

So, any other way to get the member id at that moment in the extension function?

edit 2 Ah nevermind, I already moved the hook above the cleanup 😊 Thanks!

       

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.