News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Verify members additional groups in custom script

Started by Guy Verschuere, December 27, 2013, 07:11:38 AM

Previous topic - Next topic

Guy Verschuere

Hi all,

I wish to add and remove members from additional group 54 using a custom script that calculates their activity. The calculation works fine and a variable $warninglevel is set.

Problem with the code was that it adds and removes all members on every pageview. Because I also like to add a sendpm this is not acceptable.

Therefore I also pulled the addition_groups from the database.
The print_r command prints "(51,53,50,52,49)" on the screen.
But because they are stored in one column I can't find a way to put them in a array.

Any ideas on that?



$additionalgroups = $rowmemberinfo['additional_groups'];
$additionalgroups = '('.$additionalgroups.')';
echo '<br/>Additional groups for member '.$idtoquery.' - '.$rownewmembers['member_name'].': ';print_r($additionalgroups);echo ' -- ';
if($warninglevel == 1) {
if (!in_array('54', array($additionalgroups)))
{
addMembersToGroup ($idtoquery,54,'only_additional');
echo 'Member '. $idtoquery . ' added to Warning-idle group.</br>';
}
}
if($warninglevel == 0) {
if (in_array('54', array($additionalgroups)))
{
removeMembersFromGroups ($idtoquery,54);
echo 'Member '. $idtoquery . ' removed from Warning-idle group.</br>';
}
if($warninglevel == 2) {
removeMembersFromGroups ($idtoquery);
echo 'Member '. $idtoquery . ' removed from all groups.</br>';
}


Thanks for thinking with me!

margarett

explode(',' , $rowmemberinfo['additional_groups'])

Will generate an array ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Guy Verschuere

THANK YOU!

this did it :)


$additionalgroups = explode(',' , $rowmemberinfo['additional_groups']);
if($warninglevel == 1) {
if (!in_array(54, $additionalgroups)) {
addMembersToGroup ($idtoquery,54,'only_additional');

Advertisement: