Automatic Group Sign Up Not Working

Posted in

Hi

My client, TSC Signs (https://tsc.uk.net/) has Groups and Groups Restrict Categories

At some point (not sure when) they lost one of the functionalities…

When a corporate client signed up for an account the system used to automatically add their Group to their user profile based on their email domain (ie the part after the “@”)

This enabled them to automatically see their own corporate range of products.

At some point that functionality has stopped working so for now we have to check to see if a user from each company has created an account and manually add that Group to their profile. This isnt sustainable and not a great customer experience.

Any advice on how to solve this would be appreciated.

Thanks

4 Responses to Automatic Group Sign Up Not Working

  1. George July 3, 2023 at 10:47 am #

    That’s awesome Philip, thanks for sharing your snippet with us.

    Cheers

  2. Philip Levy July 2, 2023 at 9:41 am #

    If this helps anyone else the bespoke code is:

    / add users to group based on domain
    add_action( ‘user_register’, ‘group_registration_save’, 10, 1 );

    function group_registration_save( $user_id ) {

    if ( isset( $_POST[‘user_email’] ) ){
    $domain = substr(strrchr($_POST[‘user_email’], “@”), 1);
    echo $domain;
    //update_user_meta($user_id, ‘first_name’, $_POST[‘first_name’]);
    if ( $group = Groups_Group::read_by_name( $domain ) ) {
    Groups_User_Group::create(array( ‘user_id’ => $user_id, ‘group_id’ => $group->group_id ) );
    }
    }
    }

  3. Philip Levy July 2, 2023 at 9:40 am #

    Thank you George for taking the time to reply. Knowing that helped direct where to look.

    Yes there was some bespoke code but at some point the client started to use the Woocommerce registration form rather than the old / standard WordPress User registration form.

    Once we started to use that form the new users automatically started to have their groups assigned against their user profile automatically based on their email domain.

    As a thought it would be a useful development to your Groups plugin to have this functionality as the code itself is very simple!

    Thanks again

    Philip

  4. George June 28, 2023 at 9:19 am #

    Hi Philip,

    Welcome to our support forum and many thanks for using Groups and its addons on your site.

    What you are describing here is actually a feature that is not supported by the core Groups plugin or any of its addons. Perhaps you are using a custom-made addon that for some reason is malfunctioning.
    Please have a look at your installation and perhaps your debug.log after enabling WP debugging.

    Furthermore and beyond this support request, your license for Groups Restrict Categories has expired since August 2020. Once you renew the license, by re-buying the plugin, you will be able to use the latest version of the plugin.

    Kind regards,
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share