Hi,
I'm wanting to use the postAccountCreation hook in create_account.php, and utilise the customer_id. However the customer_id is part of the object class which is private.
How you I obtain the value for customer_id?
customer_id create account
-
- Lead Developer
- Posts: 2637
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 181 times
Re: customer_id create account
Code: Select all
$GLOBALS['customer_data']->get('id', $GLOBALS['customer_details'])
Re: customer_id create account
ok, using the postAccountCreation hook call defined in create_account.php in 1.0.7.11, I could use code to create an entry in the action_recorder table.
Now, in 1.0.7.12, postRegistration hook is added to replace postAccountCreation. I adjusted my hook accordlingly, but it does not seem to call the hook.
so I'm confused. What do I need to do to fix my existing hook?
Now, in 1.0.7.12, postRegistration hook is added to replace postAccountCreation. I adjusted my hook accordlingly, but it does not seem to call the hook.
so I'm confused. What do I need to do to fix my existing hook?
-
- Lead Developer
- Posts: 2637
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 181 times
Re: customer_id create account
My guess would be that you need to change the name so that the hook runs at the right time. I would have expected it to run after the customer_id is set automatically. Perhaps I should rename the redirect. But anyway, try a filename like _01a_anything.php -- don't forget to adjust the class name to match, which would include a double-underscore (one from the name and one as a separator from the group).
Re: customer_id create account
Thank you Matt, changing the file/class name as suggested worked. I'm not totally understanding why?
Prior to the file name change the hook wasn't being called, checked by using an alert box in script.
Any way, thanks again!
Prior to the file name change the hook wasn't being called, checked by using an alert box in script.
Any way, thanks again!
-
- Lead Developer
- Posts: 2637
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 181 times
Re: customer_id create account
Hooks are sorted before running to give a consistent sequence (thanks John). Order:
1. Things that start with numbers.
2. Things that start with capital letters.
3. Things that start with underscores.
4. Things that start with lower case letters.
The redirect used to start with an underscore (it will be renamed for 1.0.7.14 so that it starts zz_ which will sort before anything short of zza). I'm guessing that your hook started with a lower case letter. So it sorted after the redirect, which ended execution of the page before the hook ran. The hook was there and was scheduled to be run. But the redirect happened before it actually did.
Renaming to _01a_anything made it sort before the redirect (1 sorts before 4) but after _01_post_login (_ sorts before a).
What you did should work and will work in the future. But changing the name makes it work with the way things are right now.