How do I get a user attribute?
Permalink
I'm creating a page on_user_add and I want to get the new user's attributes. I've created 3 attributes that are required on registration:
firstName
lastName
phoneNumber
I want to be able to get all of these.
firstName
lastName
phoneNumber
I want to be able to get all of these.
Thanks, I read that and tried to incorporate that but I must have done something wrong. Can you show me how to incorporate this into my attached file?
I don't think user attributes are accessible during registration, which is when I'm trying to grab them.
It turns out that tash was hooking into the on_user_add event, which actually fires first, then the attributes are assigned to the $ui object that is returned.
What ended up working is extending a new event 'on_user_attributes_saved' and firing this event after the user attributes are saved in /controllers/register.php...
And added this event to site_events.php like a normal event.
This is kind of the simple version, but it's what worked. I'll let tash put up the full code if he wants ;)
What ended up working is extending a new event 'on_user_attributes_saved' and firing this event after the user attributes are saved in /controllers/register.php...
if (is_object($process)) { foreach($aks as $uak) { $uak->saveAttributeForm($process); } // added this next line to hook into when the user is fully active Events::fire('on_user_attributes_saved', $process);
And added this event to site_events.php like a normal event.
This is kind of the simple version, but it's what worked. I'll let tash put up the full code if he wants ;)
hereNT, thanks for your help yo. To help some peeps out that might want to do this in the future I'm including my code below:
// My site_events.php file <?php Events::extend('on_user_attributes_saved', 'CreateUserPage', 'pageCreate', 'models/create_user_page.php'); ?> //My create_user_page.php file <?php class CreateUserPage extends Object { public function createPage($ui) { // Load the collection types and page models Loader::Model('collection_types'); Loader::Model('page'); // Set collection type $ct = CollectionType::getByHandle('left_sidebar');
Viewing 15 lines of 68 lines. View entire code block.
I tried to explain what's happening a little better here:
http://local.werstnet.com/blog/a-more-useful-on-user-add-event-for-...
That link may not last forever, it should be moving to
http://www.werstnet.com/blog/a-more-useful-on-user-add-event-for-co...
Soon :)
http://local.werstnet.com/blog/a-more-useful-on-user-add-event-for-...
That link may not last forever, it should be moving to
http://www.werstnet.com/blog/a-more-useful-on-user-add-event-for-co...
Soon :)
This was driving me bonkers!
Thanks for posting this solution, Jeremy!
Thanks for posting this solution, Jeremy!
http://stratisdesign.com/stratisdesign/blog/programming/hello-user-...