- This topic has 6 replies, 3 voices, and was last updated 5 years, 5 months ago by
Ashley T.
-
AuthorPosts
-
June 2, 2016 at 7:34 pm #10004556
Vanessa Grimes
ParticipantI have a custom plugin that I would like to fire ~after~ a user has registered with the pie register screen, but before verification. The custom plugin code is using the ‘user_register’ action hook at which time I query the user metadata for the register_type. Using WP_DEBUG_LOG and error_log, I can see that inside my function, the register_type metadata is not there yet. So apparently hooking into user_register is too early. Can you please recommend an appropriate action to hook into once the registration is complete but before the user verifies?
TIA
-VGJune 3, 2016 at 3:20 pm #10004557Pie Register
ParticipantHello,
You can “pie_register_after_register_validate” hook that fires before activating the user. This action provides you user object that were newly created into the system.
Best
June 3, 2016 at 4:59 pm #10004558Vanessa Grimes
ParticipantThank you Hasnain, I just tried using that hook but I have a few problems with doing so.
First, is that when I use that hook, the user’s meta-data still appears to not be set yet. Here is my code:
function __construct() { add_action( 'pie_register_after_register_validate', array( $this, 'registered' ) ); ... } function registered( $user ) { $user_ID = get_current_user_id(); $regtype = get_user_meta($user_id,"register_type",true); error_log($regtype, 0); }
The log file shows a blank line for $regtype.
My second issue is that if I want my plugin to work for everyone, I need to be able to hook into a common action that is available regardless of whether your plugin is installed or not, so when I originally asked for another action hook, I wasn’t expecting you to suggest a proprietary one. I was hoping you had a do_action somewhere that calls the standard WP actions to complete the process, such as the user_register action. Lastly, I still have a separate hook for the user_register action, and that does fire AFTER your proprietary action, and with the same get_user_meta command, the register_type value is still not in the database. If it’s available in pie_register_after_register_validate and that fires before user_register, then I shouldn’t need pie_register_after_register_validate, and should just need user_register, but the data’s just not there. Or am I using get_user_meta incorrectly? I’m sorry, this is my first try at developing this plugin, but I thought for sure that is the proper way to use get_user_meta.
Thanks for any additional help you can provide.
-VGJune 6, 2016 at 4:09 pm #10004559Pie Register
ParticipantHello,
Thanks for your more details, well, the user_register is the first hook that available after the user registers so on that hook the register_type meta wont be available, to have the register_meta available I would recommend you to use pie_register_after_register hook.
Best
June 7, 2016 at 5:06 pm #10004562Vanessa Grimes
ParticipantThank you Hasnain. That action hook does work to get the register_type. Can I make a request that your next version move up the logic that creates this meta data to be ~before~ the user_register action since all meta data should already be available by that time and allows other developers to be more generic?
Thanks again
-VGJune 9, 2016 at 12:33 pm #10004564Pie Register
ParticipantHello,
I am glad you got it working. Well, since PR uses wp registration functions to register a user so its not possible to have user meta available on or before user_register hook, however, perhaps we will try our best to have other global hook available on the registration.
Thanks
October 27, 2017 at 5:11 pm #10005254Ashley T
ParticipantI’m also working on a plugin that will create a draft post when a user registers. Tried using
pie_register_after_register
as suggested in this thread, but it’s still not wanting to work.I’ve narrowed it down to having the Paypal active and installed on the reg form. Draft post is created as expected without the Paypal gateway active. As soon as I activate and register another test user…no draft post.
I started my own topic on this, but haven’t had any bites yet. Any help is appreciated! My code is as follows:
add_action( 'pie_register_after_register', 'restaurant_profile_create', 10, 1 ); function restaurant_profile_create( $user_id ) { // Get user info $user_meta = get_user_meta( $user_id, 'pie_text_7', true ); // Create a new post $user_post = array( 'post_author' => $user_id, 'post_title' => $user_meta, 'post_content' => print_r( $user_meta, true ), 'post_type' => 'post', ); // Insert the post into the database $post_id = wp_insert_post( $user_post ); }
-
AuthorPosts
- The forum ‘Pie-Register 2.0 Support’ is closed to new topics and replies.