Page 1 of 1

Change members record to a different group

Posted: 2020-08-16 07:08
by bruceholt
I have been trying to limit the number of records that a user can have in a particular table if they belong to a certain group but in another group they can have more records.

I set the number of records in the hooks file but realised that if I change the user to a different group, the membership_userrecords table says that the record belongs to the previous group.

Is there any way to change this without having to do it one by one which isn't practical?

Re: Change members record to a different group

Posted: 2020-08-19 10:53
by angus
Not sure how you assign the groups bruceholt, if you do from the admin pages it should automatically reassign them but if you do this in hooks then maybe this will work, not tried it so use with care?

Code: Select all

$group = $memberInfo[groupID];                                           //Assumes you have already moved the user to the new group?
	 $username = $memberInfo[username];
     sql("UPDATE `membership_userrecords` SET `membership_userrecords`.`groupID` = $group WHERE `membership_userrecords`.`memberID` = '".$username."' ", $eo);

Re: Change members record to a different group

Posted: 2020-08-20 07:52
by bruceholt
Hi Angus,

Thanks. Which hooks file should I put that in?

Re: Change members record to a different group

Posted: 2020-08-20 20:17
by angus
Can I check how you are updating the user from one group to another?

Re: Change members record to a different group

Posted: 2020-08-21 05:54
by bruceholt
Through admin, Angus.

Re: Change members record to a different group

Posted: 2020-08-21 14:18
by angus
from my understanding then Bruce this should be applied automatically after you amend the group

Re: Change members record to a different group

Posted: 2020-08-22 02:49
by bruceholt
Thanks Angus. From what I can tell, the user records in the table stay as the previous group.