Your cart is currently empty!
Automatic Group Sign Up Not Working
—
by
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
Posted in Groups
Comments
4 responses to “Automatic Group Sign Up Not Working”
That’s awesome Philip, thanks for sharing your snippet with us.
Cheers
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 ) );
}
}
}
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
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