skip to Main Content
Groups

Request

This is a fix for a bug that came through regarding the automatic addition of the  Registered group to users. The client’s site depended on users only being a member of a single group.

My fix is specific for using WooCommerce since it’s using the woocommerce_before_cart filter, but it could be modified to use any filter.

Required Plugins

Code

<?php

add_filter ( 'woocommerce_before_cart', 'remove_user_from_registered_group' );
function remove_user_from_registered_group ( ) {

        $user_id              =  get_current_user_id( );
        $registered_group_id  =  1;
        $group_delete         =  new Groups_User_Group( $user_id, $group_id );
        $group_delete::delete ( $user_id, $registered_group_id );
}

?>

Disclaimer

Maje Media LLC cannot be held responsible for the functionality of this code. Please make sure you test it on a development site before adding the code to your production website. There is no support available for this (and other) code snippet(s) posted on this website. If you’d like Maje Media to do custom development to help with your custom implementation please send a contact request.

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top