Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
Replace this link here
add_user_to_blog( $new_blog, $post_id, $user_info->roles );
with
add_user_to_blog( $new_blog, $post_id, 'athlete');
Please let me know if this helps.
Thanks,
Shane
It worked perfect!
I had a previous question about being able to approve new users before they get their account.
Need some advice and maybe tips. I thought you might be able to make 2 separate forms. One where you send a request to become a member on the page. When I receive a request that I want to approve, I reply with a message / email with the link to the registration form. That is hidden for other visitors of the website.
If it works, do you have a good solution to the first form? That you can reply directly from the admin dashboard with a link to the registration form?
And that link, can it be unique to any prospective member, so nobody else will access that link?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
To approve the user would require additional custom code and hooks which would be out of the scope of what I can assist with .
The 2 forms idea would work well. However you would need to use this plugin to approve the user registration.
https://wordpress.org/plugins/wp-approve-user/
Then you can send the form to them in an email which would have the hook that i've assisted with you the auto registration of the site.
Please let me know if this helps.
Thanks,
Shane
Hi again!
Thank you so far for all the help! I have now created a user registration for with woocommerce membership payment. All is good, the registration och payment works. But the user is not registered.. Its the same form we have been working on: looks like this now :
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==829)
{
$user_info = get_userdata( $post_id );
if ( isset( $user_info->user_login ) ) {
$main_site = 'weareyou.online'; // Add your main domain here
$new_blog = wpmu_create_blog( $main_site, '/'.$user_info->user_login.'/', $user_info->user_login.''.$user_id, $user_id , array( 'public' => 1 ) );
add_user_to_blog( $new_blog, $post_id, 'author');
wp_delete_user( $post_id);
}
}
}
Its not the same form ID but otherwise the same. Do you know why the user is not registered?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
Are you using our Toolset Payment to do the registration ?
Please let me know.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
Try using this.
add_action( 'cred_commerce_after_order_completed', 'my_hook', 10, 1 );
function my_hook( $data ) {
// if a specific form
if ($data['cred_form_id']==829)
{
$user_info = get_userdata( $data['cred_post_id'] );
if ( isset( $user_info->user_login ) ) {
$main_site = 'weareyou.online'; // Add your main domain here
$new_blog = wpmu_create_blog( $main_site, '/'.$user_info->user_login.'/', $user_info->user_login.''.$user_id, $user_id , array( 'public' => 1 ) );
add_user_to_blog( $new_blog, $data['cred_post_id'], 'author');
wp_delete_user( $data['cred_post_id']);
}
}
}
Please try this and let me know if it helps.
Thanks,
Shane
Hmm the user is still not created
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
Are you using test payments ?
Also is the order status in woocommerce being set to completed ?
This hook only works if the order status in Woocommerce is set to completed.
Thanks,
Shane
We are using test payments. The user is created when change the order status to completed, but the new blog/site is not created
The user is added to main site (weareyou.online) as a subscriber
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
Would you mind allowing me to have access to the site where you have this setup ?
I would like to do some debugging to see why it's not working.
Thanks,
Shane
Did you find what the problem is?:)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Nicklas,
I checked on this for you but there doesn't seem to be a form that the code should target.
Could you let me know which form this should target?
Thanks,
Shane
No i only have one form, see the attached picture..