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 Maurice - August 17, 2010

Hi zip222,

that's what I do 2 right now its pretty cool and easy I even make portlets that way.

<?php if ($CURRENT_USER['show_career_planning']): ?>
<?php include('portlets/planning.php'); ?>
<?php else: ?>
<?php include('portlets/control_panel.php'); ?>
<?php endif ?>


I can even the Section Access how ever its all very basic but powerful and easy it could be done beter in a different way i think but its a start.

Greetz M
-------------------------------------------

Dropmonkey.nl

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 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!