Membership Plugin Guidance

13 posts by 4 authors in: Forums > CMS Builder
Last Post: August 31, 2010   (RSS)

By zip222 - August 16, 2010

I have the successfully completed the basic setup for the membership plugin, but I was wondering if you could give me some general guidance on how to get it to show/hide content for each user.

Small group of users (10)
A separate multi-record listing that a user will see once logged in, but specific records need to be hidden for each user

Re: [zip222] Membership Plugin Guidance

By Jason - August 16, 2010

Hi,

How are you deciding which records are displayed for an individual user?

Can you provide me with the code you have so far?

Let me know and I can take a closer look at this.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership Plugin Guidance

By zip222 - August 17, 2010

That's actually what I am looking for guidance on. How should I approach setting which records are displayed for each user? In theory I would like there to be a list of checkboxes in the record editor that the administrator can select. And the checkbox list should only include certain users - it shouldn't show every user. this list could be determined by adding a checkbox to the user record.

Re: [zip222] Membership Plugin Guidance

By Jason - August 17, 2010

Hi,

Yes, this can be done. Try this:

Edit the User Accounts section and add a checkbox field called display_record. Go through the user accounts and check the box for users you want to display as an option in the other sections.
Next, edit the section where you would like to select users to view certain records. Add a list field called display_record. For "Display As" you can select either pulldown (multi value) or checkboxes (multi value). For "List Options" select "Get options from MYSQL Query (advanced)". In the box below, add this code:
SELECT num, username
FROM `<?php echo $TABLE_PREFIX ?>accounts` WHERE display_record=1


Then save. When you go into records in that section now, you can select which users will be able to see those records.

Finally, when using the getRecords function on your viewer page, you can use code that looks like this:

list($listingsRecords,$listingsMetaData)=getRecords(array(
'tableName' => 'listings',
'allowSearch' => false,
'where' => "display_record LIKE '%\t".intval($CURRENT_USER['num'])."\t%'",
));


This code will only select records from the listing table where the current user has been selected from the list field we created.

Give that a try.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership Plugin Guidance

By zip222 - August 17, 2010

I think this is exactly what I am looking for. let me give this a try and I will let you know how it goes.

thanks!

Re: [zip222] Membership Plugin Guidance

By zip222 - August 17, 2010 - edited: August 17, 2010

Perfect, but I have a followup question:

How do I modify the page where statement to check for a second condition...

'where' => "display_record LIKE '%\t".intval($CURRENT_USER['num'])."\t%'",
OR
'where' => "$CURRENT_USER['staff']=1",


so basically if the user account is "staff" they get to see all listings.

Re: [zip222] Membership Plugin Guidance

By Jason - August 17, 2010

No problem. What you can do is set up a $where variable like this:

$where="";

if(!$CURRENT_USER['staff']){
$where = display_record LIKE '%\t".intval($CURRENT_USER['num'])."\t%'";
}


list($listingsRecords,$listingsMetaData)=getRecords(array(
'tableName' => 'listings',
'allowSearch' => false,
'where' => "$where",
));


So if the current user is set as staff, the where clause will be empty and therefore return all records.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership Plugin Guidance

By zip222 - August 17, 2010

Awesome! Works perfect.

Re: [Jason] Membership Plugin Guidance

By zip222 - August 31, 2010

bringing back a previous post to ask a follow-up question:

How do i modify this statement:
if(!$CURRENT_USER['staff']){
$where = reviewer_conflicts LIKE '%\t".intval($CURRENT_USER['num'])."\t%'";
}

to do basically the opposite, meaning:
if(!$CURRENT_USER['staff']){
$where = reviewer_conflicts IS NOT LIKE '%\t".intval($CURRENT_USER['num'])."\t%'";
}


"reviewer_conflicts" is a checkbox list and if they check a box I don't want the CURRENT_USER to see it on the page.

thanks!