Navigation überspringen

[Gelöst] User Form creates a subscriber user, not the user type indicated

This support ticket is created vor 1 Jahr, 10 Monaten. 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.

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

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 1 Jahr, 10 Monaten.

Assistiert von: Minesh.

Author
Artikel
#2647639
Screen Shot 2023-09-26 at 11.18.02 AM.png
Screen Shot 2023-09-26 at 11.14.35 AM.png
Screen Shot 2023-09-26 at 11.14.26 AM.png

I am setting up a membership using the Toolset documentation provided.
I have different levels of membership so I created different levels using Access: Premium, Basic, Standard

When I attached the subscription product to the user Form it creates only users of the type Subscriber. This is a setting that is set in Woocommerce.

The User form created in Toolset should create users with types of: " Premium, Basic, Standard"
Is there a way to over ride the Woocommerce setting to use the Toolset user forms?

#2648283

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the Toolset Forms commerce "cred_commerce_after_order_completed" hook.

More info
- https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_order_completed

For example:
- You can add the following code to "Custom Code" section offered by Toolset:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
OR
- To your current theme's functions.php file:

add_action( 'cred_commerce_after_order_completed', 'func_set_custom_role', 10, 1 );
function func_set_custom_role( $data ) {
    // check for a specific form
    if($data['extra_data'][0]['cred_form_id'] == 99999) {
        $user_id = $data['user_id'];
        $user = new WP_User( $user_id );
 
        // Remove role
        $user->remove_role( 'subscriber' );
 
        // Add role
        $user->add_role( 'your-role-slug' );
    }
}

Where:
- Replace 99999 with your original form ID.
- Replace 'your-role-slug' with your original role slug.
- You are welcome to adjust the code as per requirement based on your different product IDs and set different role as required.

#2648469
Screen Shot 2023-09-28 at 11.44.59 AM.png

Hi Minesh,
Thank-you for your reply.
That line of codes doesn't seem to be working. The users are still showing up as subscribers
versteckter Link

I think Woocommerece is assigned the subscriber role after purchase?

#2648813

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

#2648845

Hi Minesh,
I think this may work for us.

Thank-you so much for your time!