Hi @flowingweb
You can try this action hook:
+ um_post_registration_awaiting_admin_review_hook
– $user_id
– $args
and then use this code to auto-login a user so they can process the stripe with their account:
UM()->user()->auto_login( $user_id );
Regards,
Thread Starter
Florian
(@flowingweb)
Hi,
thanks for your input! I’ve overlooked that hook completely.
I’ve changed my code but unfortunately, it still doesn’t work…
add_action( 'um_post_registration_awaiting_admin_review_hook', 'nvz_user_register', 10, 2 );
function nvz_user_register( $user_id, $args ) {
//do stuff
}
The user gets the status ‘awaiting_admin_review’ in de database, I can see him in users.php in the admin but the hook is not executed. All other UM hooks are working fine (um_after_user_updated, e.g.), so my file is correctly loaded.
Do you have any other suggestions?
Regards, Florian
WP version: 5.3.1
UM version: 2.1.2
PHP version: 7.3.12
Hi @flowingweb
Have you tried making the priority number to 1 and see if this makes a difference?
add_action( 'um_post_registration_awaiting_admin_review_hook', 'nvz_user_register', 1, 2 );
function nvz_user_register( $user_id, $args ) {
//do stuff
}
Regards,
Thread Starter
Florian
(@flowingweb)
Hi,
I’ve already tried 5 to test it what didn’t work. Also priority 1 doesn’t help.
I’ve changed the code so it will only email me to check if the code is executed and no other “problems” get raised by my code, but I’m getting nothing…
add_action( 'um_post_registration_awaiting_admin_review_hook', 'nvz_user_awaiting_admin_review', 1, 2 );
function nvz_user_awaiting_admin_review( $user_id, $args ) {
mail("[email protected]", "nvz_user_awaiting_admin_review", "It's working");
/*
$wp_user = new WP_User( $user_id );
if ( !empty( $wp_user->roles ) && is_array( $wp_user->roles )){
$contributie = 0;
if(in_array('Lid', $wp_user->roles))
$contributie = intval(get_field('contributie_lid', 'option'));
if(in_array('Student', $wp_user->roles))
$contributie = intval(get_field('contributie_student', 'option'));
if($contributie > 0){
$stripe = new Stripe();
$input = ["user_id" => $user_id, "amount" => $contributie, "description" => "Lidmaatschap ".$wp_user->first_name .' '.$wp_user->last_name, "return_url" => 'https://'.$_SERVER['HTTP_HOST'].'/lidmaatschap-betaald/'];
$stripe->Betalen($input);
}
}
*/
}
add_action( 'um_after_user_updated', 'nvz_after_user_updated', 10, 3 );
function nvz_after_user_updated( $user_id, $args, $userinfo ) {
$user = new Lid($user_id);
$user->Opslaan();
}
add_action( 'um_after_user_is_approved', 'nvz_after_user_is_approved', 10, 1 );
function nvz_after_user_is_approved( $user_id ) {
$user = new Lid($user_id);
$user->NieuweLidnummer();
$user->Opslaan();
}
All other functions are getting executed, but not the first… I will try it with a default template and let you know.
Thread Starter
Florian
(@flowingweb)
OK, also as a child theme of Twentytwenty all other hooks are working but still not the first…
Hi @flowingweb
Did you assign a specific role to the Register form? If so, could you please check if the Register options in that Role has the Admin pending review as the account status?
Regards,
Thread Starter
Florian
(@flowingweb)
Hi @champsupertramp ,
yes, the user can select one out of two roles (normal and student), both roles are setup to require the admin review. You have the options to display a message or redirect to another page after registering. I tried both options without any change to my override.
Thanks for your help,
Florian
Hi @flowingweb
Could you please try changing the action hook from 'um_post_registration_awaiting_admin_review_hook' to 'um_post_registration_pending_hook' ?
Regards,
Thread Starter
Florian
(@flowingweb)
Thanks for your continuing support!
I’ve changed the hook, unfortunately without success. I’ve also tried it with priority 1.
add_action( 'um_post_registration_pending_hook', 'nvz_user_awaiting_admin_review', 10, 2 );
function nvz_user_awaiting_admin_review( $user_id, $args ) {
//do stuff
}
Hi @flowingweb
Could you please try this code snippet? Let’s see if this triggers with wp_die
add_action( 'um_post_registration_pending_hook', 'nvz_user_awaiting_admin_review', 10, 2 );
add_action( 'um_post_registration_awaiting_admin_review_hook', 'nvz_user_awaiting_admin_review', 1, 2 );
function nvz_user_awaiting_admin_review( $user_id, $args ) {
wp_die("test : {$user_id}");
}
Regards,
Thread Starter
Florian
(@flowingweb)
YESY! That works! Now I have to babystep my way to the point where my code fails… Is it the double hook call that did the job?
Thanks a lot and I wish you a pleasant Christmas π
Regards, Florian
-
This reply was modified 6 years, 5 months ago by
Florian.
Hi @flowingweb
You can test each action hook so you can determine which one fires the wp_die.
Happy Holidays π
Regards,