• Hello. good plugin. A question.

    When the user registers, WP creates 2 roles for him, both as a woocoomerce client and as an affiliate.

    How to configure so that it only registers the affiliate role? Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Juan Coronel

    (@juaancmendez)

    Hi Franklin,
    we hope you’re doing well.

    In order to achieve this, add this code in the functions.php file of your active theme:

    if ( defined( 'YITH_WCAF' ) && ! function_exists( 'yith_wcaf_new_affiliate_remove_customer_role' ) ) {
        function yith_wcaf_new_affiliate_remove_customer_role( $id ) {
            $user = get_user_by('id', $id);
            $user->remove_role( 'customer' );
        }
        
        add_action( 'yith_wcaf_new_affiliate', 'yith_wcaf_new_affiliate_remove_customer_role', 999, 1 );
    }

    This will apply to new affiliates. Try it and tell us any questions.

    Have a nice day!

    • This reply was modified 2 years, 9 months ago by Juan Coronel.

    Hello, I’ve tried adding this function to my child theme (Hello Theme), but it makes the theme crash. It might be due to the fact that the action “yith_wcaf_new_affiliate” is hooked to a different function used to register a custom field or it might not work because I’m using this plugin on a multisite. Do you have any other way of setting only the affiliate role?

    Plugin Support Juan Coronel

    (@juaancmendez)

    Hi there,
    sorry for the delay.

    The function should work fine as it simply removes the role when the affiliate is created. Could you tell us what error you get?

    We will be attentive to your response.

    Greetings.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘2 roles’ is closed to new replies.