Auto user account activation..!

Hi all,



I want to activate a particular user-group automatically, so if a user sign up for the group, it’s immediately activated.



I search the forum and i found the modification to do this, but its written for CS-Cart v1.3.x :


[quote name=‘dab’]In order to automatically activate only your wholesale membership accounts you should replace the following part of code in the “fn_users.php” file located in the “core” directory of your CS-cart installation:

<br />
	if (AREA == 'C') {<br />
		$_data['membership_status'] = 'P';<br />
	}<br />

```<br />
with this one:<br />
```php
<br />
	if (AREA == 'C') {<br />
		if ($_data['membership_id'] == 'YOUR_WHOLESALE_MEMBERSHIP_ID') {<br />
			$_data['membership_status'] = 'A';    <br />
		} else {<br />
			$_data['membership_status'] = 'P';<br />
		}<br />
	}<br />

```<br />
where "YOUR_WHOLESALE_MEMBERSHIP_ID" is the id of your wholesale membership.<br />
I hope that will help.[/QUOTE]<br />
<br />
<br />
Does anybody know how tho do this in CS-Cart v. 2.0?<br />
<br />
Thank you in advance:cool: !

I don’t use usergroups but I believe all you need to do is select it in Settings->General





[ATTACH]1819[/ATTACH]

usergroup.jpg

[quote name=‘Tool Outfitters’]I don’t use usergroups but I believe all you need to do is select it in Settings->General





[ATTACH]1819[/ATTACH][/QUOTE]





Thank you for your post. This option is not selected, but all new accounts still “awaiting approval”.



Is this a CS-Cart bug or can it be solved by another option like my first post?

[quote name=‘dennis’]Thank you for your post. This option is not selected, but all new accounts still “awaiting approval”.



Is this a CS-Cart bug or can it be solved by another option like my first post?[/QUOTE]



Look in the screenshot he posted above. The option right under the one he mentions says “Administrator must activate new user accounts.” Do not check this option if you want them automatically activated. This will make all accounts activated though. I don’t believe there is a method to only activate certain groups automatically and not others.

[quote name=‘adodric’]Look in the screenshot he posted above. The option right under the one he mentions says “Administrator must activate new user accounts.” Do not check this option if you want them automatically activated. This will make all accounts activated though. I don’t believe there is a method to only activate certain groups automatically and not others.[/QUOTE]

Would be nice to specify on each user group if it requires activation. It would also be nice if you could select one user group as the default. This is on my list of things to add to the Ideas forum once I have some points again.



Bob

[quote name=‘dennis’]Thank you for your post. This option is not selected, but all new accounts still “awaiting approval”.[/QUOTE]



You want to select that option and the one below it, do not select it.

Our settings are fine:





The second option “Administrator must activate new accounts” is not regarding the user groups… That’s for the customers account activation.



I think you guys don’t understand our point… Users can sign up for a user group but an administrator has to activate them. We are looking for a solution like the one in my first post.



Does someone know a solution for this?



Thank you!

[quote name=‘dennis’]Our settings are fine:





The second option “Administrator must activate new accounts” is not regarding the user groups… That’s for the customers account activation.



I think you guys don’t understand our point… Users can sign up for a user group but an administrator has to activate them. We are looking for a solution like the one in my first post.



Does someone know a solution for this?



Thank you![/QUOTE]



In this case try to replace the following part of code:



} elseif ($mode == 'request_usergroup') {

if (AREA == 'A' && fn_is_restricted_admin($_REQUEST) == true) {
return array(CONTROLLER_STATUS_DENIED);
}

$uid = $auth['user_id'];
if (!empty($uid)) {
$_data = array(
'user_id' => $uid,
'usergroup_id' => $_REQUEST['usergroup_id'],
);

if ($_REQUEST['status'] == 'A' || $_REQUEST['status'] == 'P') {
$_data['status'] = 'F';

} elseif ($_REQUEST['status'] == 'F' || $_REQUEST['status'] == 'D') {
$_data['status'] = 'P';
$usergroup_request = true;
}

db_query("REPLACE INTO ?:usergroup_links SET ?u", $_data);





with this one:



} elseif ($mode == 'request_usergroup') {

if (AREA == 'A' && fn_is_restricted_admin($_REQUEST) == true) {
return array(CONTROLLER_STATUS_DENIED);
}

$uid = $auth['user_id'];
if (!empty($uid)) {
$_data = array(
'user_id' => $uid,
'usergroup_id' => $_REQUEST['usergroup_id'],
);

if ($_REQUEST['status'] == 'A' || $_REQUEST['status'] == 'P') {
$_data['status'] = 'F';

} elseif ($_REQUEST['status'] == 'F' || $_REQUEST['status'] == 'D') {
$_data['status'] = 'A';
$usergroup_request = true;
}

db_query("REPLACE INTO ?:usergroup_links SET ?u", $_data);





in the “profiles.post.php” file. located in the “controllers/common” directory.

Thank you Forward! That’s what we needed!:smiley:



I added this code:



if ($_data['usergroup_id'] == '10') {
$_data['status'] = 'A';
$usergroup_request = true;

}




(10 is the number of my usergroup that needs to be activated automatically, If anyone needs to do this also, you can chance this number in your own)





Below this code:




} elseif ($mode == 'request_usergroup') {

if (AREA == 'A' && fn_is_restricted_admin($_REQUEST) == true) {
return array(CONTROLLER_STATUS_DENIED);
}

$uid = $auth['user_id'];
if (!empty($uid)) {
$_data = array(
'user_id' => $uid,
'usergroup_id' => $_REQUEST['usergroup_id'],
);

if ($_REQUEST['status'] == 'A' || $_REQUEST['status'] == 'P') {
$_data['status'] = 'F';

} elseif ($_REQUEST['status'] == 'F' || $_REQUEST['status'] == 'D') {
$_data['status'] = 'P';
$usergroup_request = true;
}






Thank you very much!

[quote name=‘dennis’]Thank you Forward! That’s what we needed!:smiley:

Thank you very much![/QUOTE]



Not at all!:slight_smile:

Hi,



have been reading this thread and I can’t seem to get this working.



The codes that forward has put up both look the same so the replacement one you have suggested is the same as the one you said to replace.



I have also added in the code that dennis put up with the group id.



When I add a new customer it doesn’t automatically activate the required user group.

Any ideas?



Thanks

Tim

Having the same problem. I inserted the code mentioned above in the appropriate spot, but when users are created they are still not automatically assigned to the designated usergroup. Any ideas?

I just paid for the mod, maybe it will be on the next update for ya