Page 1 of 1

Update only if in a specific group

Posted: 2019-04-28 12:23
by bescott53
Hello board, Ian trying to stop an update from happening if the user is. It in a certain group. It doesn’t seem to work, can someone help?

Code: Select all


function commission_approvals_before_update($data, $memberInfo, &$args){
if($memberinfo['groupID']!='3'){
$id=makesafe($selectedID);
$complete=sqlValue("select `ClaimCompleted` from `commission_approvals` where `refnum`='$id'");
if($complete=='Claim Complete') return FALSE;
}
return TRUE;
}


Re: Update only if in a specific group

Posted: 2019-04-28 13:43
by jsetzer
Try var_dump($complete); exit(); to check return value of sqlValue call

Re: Update only if in a specific group

Posted: 2019-04-28 13:51
by pbottcher
Hi,

try

Code: Select all

"select `ClaimCompleted` from `commission_approvals` where `refnum`='".$id."'"
instead of

Code: Select all

"select `ClaimCompleted` from `commission_approvals` where `refnum`='$id'"

Re: Update only if in a specific group

Posted: 2019-04-30 09:28
by bescott53
pbottcher, jsetzer thanks, here is the final code that worked

Code: Select all

function commission_approvals_before_update($data, $memberInfo, &$args){
                                
                                if($memberInfo['groupID']!='3'){
                                                $id=makesafe($data['selectedID']);
                                                $complete=sqlValue("select ClaimCompleted from commission_approvals where refnum='" . $id. "'");
                                                if($complete=='Claim Complete') 
                                                                 
                                                 return FALSE;
                                }
                                
                                return TRUE;
                                                
                }