5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 15, 2018   (RSS)

By Zicky - August 15, 2018 - edited: August 15, 2018

I'm trying to set up an events page to display Church Events to members based on their permission levels, and also filter records based on Date greater than Now.

The code I'm using below works for filter member permission levels, but when I add the AND "(date >= NOW())" nothing seems to happen and it still displays all events even if they are past tense. Anyone have any suggestions on how to get this working and filtering out event records that are past tense.

$paramseventsRecords = array( 'tableName' => 'events', 'perPage' => @$perPage ? $perPage : '6', 'orderBy' => 'date', 'loadUploads' => true, 'allowSearch' => true, 'where' => 'membership_access = "Public"' AND "(date >= NOW())" ); if(@$CURRENT_USER['membership_user_type'] == 'Congregation') { $paramseventsRecords['where'] = 'membership_access = "Public" OR membership_access = "Congregation"' AND "(date >= NOW())"; } if(@$CURRENT_USER['membership_user_type'] == 'Administration') { $paramseventsRecords['where'] = 'membership_access = "Public" OR membership_access = "Congregation" OR membership_access = "Administration"' AND "(date >= NOW())"; } if(@$CURRENT_USER['membership_user_type'] == 'Leadership' AND "(date >= NOW())") { $paramseventsRecords['where'] = 'TRUE'; } list($eventsRecords, $eventsMetaData) = getRecords($paramseventsRecords);

Thanks, Zick

In response to: [url "https://www.interactivetools.com/forum/forum-posts.php?postNum=2235310#post2235310"]Website Membership user type / user levels / user permissions and display of data[/url], ...

Hi Zick,

It looks like there are some mismatched quotes in your code; the single quote needs to surround the entire where statement and the double quotes (") should be removed from around the date clause. Try adjusting the code so it follows this general format.


'where' => 'membership_access = "Public"' AND "(date >= NOW())"


'where' => 'membership_access = "Public" AND date >= NOW()'

Additionally, for the statements with multiple membership access levels, I would recommend wrapping those in brackets, such as:

$paramseventsRecords['where'] = '(membership_access = "Public" OR membership_access = "Congregation" OR membership_access = "Administration") AND date >= NOW()';

Let me know if that helps with your issue, or if I can help with anything else.  


PHP Programmer

Hi Zick,

It looks like there is a similar formatting issue here - you'll want to add the "AND..." part inside of the quotes in mysql_escapef(). So for example, something like this:

'where' => mysql_escapef('MONTH(date) = ? AND YEAR(date) = ?', $cMonth, $cYear) AND 'membership_access = "Public"',

Should look like this:

'where' => mysql_escapef('MONTH(date) = ? AND YEAR(date) = ? AND membership_access = "Public"', $cMonth, $cYear),

I hope this helps!

PHP Programmer


Thanks a ton!!! I got this working now. I really appreciate the help.