• Hi

    I’d like to add all new users into a group. The registration goes over woocommerce form.

    add_action('woocommerce_created_customer', 'add_to_UAM');
    
    function add_to_UAM($user_id) {
    	$wp_uid=$user_id; //WordPress user ID
      	$userGroupId=6; // Group ID to be updated
    
      	global $userAccessManager;
    
      	$uamAccessHandler = $userAccessManager->getAccessHandler();
      	$uamUserGroup = $uamAccessHandler->getUserGroups($userGroupId);
    
      	$uamUserGroup->addObject('user', $wp_uid);
     	$uamUserGroup->save();
    }

    I’ve added this code into the functions.php. That’s the error:

    Fatal error: Call to a member function getAccessHandler() on a non-object (at this line: $uamAccessHandler = $userAccessManager->getAccessHandler();)

    Is an import missing or something? Maybe someone can help my out that would be great.

    btw is there an api? can’t find it XD

    https://www.ads-software.com/plugins/user-access-manager/

  • The topic ‘Set group while registration’ is closed to new replies.