Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember General Questions › Execute custom function after registration of a specific level – API or Hooks?
Tagged: Custom, function, hook, registration
- This topic has 13 replies, 5 voices, and was last updated 7 years, 1 month ago by admin.
-
AuthorPosts
-
June 27, 2011 at 2:42 am #3664akeith2002Member
I am trying to have a post autogenerated everytime a user registers under a specific type. For instance, I have 2 different users, Coaches and Athletes. When an athlete signs up I want to create a post with his name as the title. I already have the WordPress script created to do that I just need some way of attaching and running it when that specific type of user account is created. Does anyone know how I could do this?
Thanks!
June 27, 2011 at 5:36 am #33713amin007ParticipantUpdate: The following action hook can do this now:
https://www.tipsandtricks-hq.com/wordpress-membership/member-registration-completion-hook-866
We can add a hook that will get triggered after a registration event and it will pass an array with all the details of the user who just registered. Will that help?
June 27, 2011 at 12:37 pm #33714akeith2002Memberwow… why yes I think it will help. Is that something I will just copy and paste in or is it going to be in the next release? if so, when will that be released.
Thanks!!!!!
I didn’t expect a reply this fast and with someone willing to help me. I appreciate it.
June 27, 2011 at 4:55 pm #33715akeith2002MemberI am in the need for some sort of resolution immediately (as all jobs are!). Working on a freelance project and I am a little behind.
Thanks!
June 28, 2011 at 12:20 am #33716amin007ParticipantI have added a hook for this. You can now add the following code in your plugin or theme’s function file to listen for member registration and do something when this even occurs:
function handle_eMember_registration_complete_event($member_data)
{
//The following line will print all the member details that got passed to this function via the $member_data data. You can use this data however you like it.
print_r($member_data);
}
add_action('eMember_registration_complete','handle_eMember_registration_complete_event')Everytime a member registers the “handle_eMember_registration_complete_event” function will get triggered and the “$member_data” array will contain all the details of this member.
June 28, 2011 at 3:00 am #33717akeith2002MemberI can’t express how top notch you guys are!
September 2, 2011 at 10:37 pm #33718akeith2002MemberHow can I get custom registration fields to show up in the $member_data array?
September 3, 2011 at 5:09 am #33719adminKeymasterI updated this hook to send the custom field data in a separate array. Use the following sample code to find out how it works:
function handle_eMember_registration_complete_event($member_data,$custom_fields)
{
//The following line will print all the member details that got passed to this function via the $member_data array.
//You can use this data however you like it.
print_r($member_data);
echo "<br />Custom fields data shown below<br />";
print_r($custom_fields);
}
add_action('eMember_registration_complete','handle_eMember_registration_complete_event',10,2);September 4, 2011 at 7:16 pm #33720akeith2002MemberTHANK YOU so much
June 24, 2016 at 3:11 am #33721FrankMemberHey Admin,
I know that this is an older post, but can you expand on the explanation of the function above?
Thanks,
Frank
June 24, 2016 at 4:24 am #33722adminKeymasterLet me know what you want explained so I know what you are after.
June 24, 2016 at 3:36 pm #33723FrankMemberHey Admin, I figured it out. I’m just looking at pushing the code I wrote in php into a plugin instead of it hanging off of the back end of the theme’s functions.php file.
I didn’t realize that it would post my results right on the web page that was posted, thus tell me exactly what I needed to know.
Frank
October 10, 2017 at 1:55 pm #33724Viviana.cerruttiMemberHi, is there a similar function to add after a member has updated their profile??? Thanks
October 10, 2017 at 11:26 pm #33725adminKeymasterWe have the following action hook that is triggered after a member updates his profile. You can use it to execute your customer function.
eMember_profile_updated
Below is an example snippet of code showing how you can use it:
add_action('eMember_profile_updated', 'run_my_custom_function', 10, 2);
function run_my_custom_function($fields, $custom_fields){
$member_id = $fields['member_id'];
$username = $fields['username']
//A member ($username) has updated the profile. Do something...
} -
AuthorPosts
- You must be logged in to reply to this topic.