adding a variable where clause based on a user id

adding a variable where clause based on a user id

TwiggitTwiggit Posts: 13Questions: 5Answers: 0

I have several Editor panels that I have been mandated to modify for one user (uid) to limit results only to where the country is ENG or WLS. The rest of the users need to see everything.

I thought I could do with something like the script below but apparently not. Can someone help me out and let me know the best way to accomplish this?

if($_SESSION['uid']=== 1983){
$uk_where = "->where( function ( $q ) {
$q
->where('crm.primary_profile.country', 'WLS', '=')
} ); ";
}else{
$uk_where = ' ';
}

and echoing out $uk_where after the joins but it doesn't work. Any help would be appreciated

Answers

  • allanallan Posts: 65,813Questions: 1Answers: 10,949 Site admin

    Your $uk_where variable there contains a string which some PHP code in it. You need to actually execute the code, not just make a strong out of it. You would do something like:

    if($_SESSION['uid']=== 1983){
      $uk_where = $editor->where( function ( $q ) {
        $q->where('crm.primary_profile.country', 'WLS', '=')
      } );
    }
    

    If that doesn't help resolve the issue for you, can you show me your full script so I can help you insert the condition in the right place?

    Allan

  • TwiggitTwiggit Posts: 13Questions: 5Answers: 0

    Thanks for the speedy response Allan the help is much appreciated.

Sign In or Register to comment.