Reputation: 43
There is a post of a similar name but the answer shown there is not working for me.
i'm trying to get the $user_id of the user as they register for my site and use that variable in a subsequent after form submission hook so
add_action( 'gform_user_registered', 'send_user_email', 10, 4 );
function send_user_email($user_id, $feed, $user_pass) {}
is the hook with the $user_id variable
add_action("gform_after_submission_1", "input_fields1", 10, 2);
function input_fields1($entry, $form) {}
is the hook to use to use to process the form data after submission.
i have tried the follwing:
add_action( 'gform_user_registered', 'send_user_email', 10, 4 );
function send_user_email($user_id, $feed, $user_pass) {
var_dump($user_id.' '. 'a');
add_action("gform_after_submission_1", "input_fields1", 10, 2);
function input_fields1($entry, $form) {
global $user_id;
var_dump($user_id.' '.'b');
}
}
this returns "29 a" which is the first Var_dump and " b" but not "29 b" which is what i would expect for the second var_dump
is my PHP wrong or have i miss understood how these hooks work?
i also tried
add_action("gform_after_submission_1", "input_fields1", 10, 2);
function input_fields1($entry, $form) {
add_action( 'gform_user_registered', 'send_user_email', 10, 4 );
function send_user_email($user_id, $feed, $user_pass) {
var_dump($user_id.' '. 'a');
}
global $user_id;
var_dump($user_id.' '.'b');
}
this returns " b" without the variable and no " a" at all
Upvotes: 0
Views: 343
Reputation: 43
i now realise that i don't need to do this. The 'gform_user_registered' hook also contains the same $entry variable i was trying to use in conjunction with the $user_id variable so these is no need to move the variable between hooks, as i can do eveything i need to do within the one hook function.
Upvotes: 1