Skip Navigation

[Resolved] Add site to new user, multisite.

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 50 replies, has 2 voices.

Last updated by Shane 5 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1140419

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

#1143706

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?

#1143864

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

#1145779

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?

#1145855

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

#1146081

I followed this tutorial: https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/
And use Woocommerce as paymen.. 🙂

#1146572

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

#1146580

Hmm the user is still not created

#1146588

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

#1146633

We are using test payments. The user is created when change the order status to completed, but the new blog/site is not created

#1146677

The user is added to main site (weareyou.online) as a subscriber

#1146713

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

#1147244

Did you find what the problem is?:)

#1148151

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

#1148157
userformtoolset.jpg

No i only have one form, see the attached picture..

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.