Showing articles only for members with a specific member level

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 20, 2013   (RSS)

Hi All,

It’s been a long day and my brain is getting fried. I have a feeling this is simple to do, but I’m having a bit of trouble getting my head around it. I hope someone is willing to come to my rescue.

In a site that I’ve inherited, there’s a multi-record section (called articles). Each record contains one article written by a member author.

Each member author can have a membership level of either free, intermediate, or master. Currently, this membership level value is stored in a text field in the accounts database, together with some other text, however I have set up a separate field for future writer’s accounts. ( so I guess I’ll need to use an OR and possibly strpos on the list viewer to accommodate both the old system and the new one.)

What I'm after is that on a “featured writer’s” list page, I need to show only those articles written by members with “master” level membership.

Here’s kind of a schematic of what I’m thinking:

<?php foreach ($articlesRecords as $record): ?>
1) check the accounts database for the membership level of the matching createdByUserNum record.
2) If the author’s membership level is “master”, show some information from that articles record.
<?php endforeach ?>

Thanks in advance,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - November 19, 2013

Hi Jerry, 

What's an estimate of the number of articles and authors you expect?

One way to do it is to do a query to get all the usernums who have a "master" level membership, then another query to load all articles that have been created by a user in that list of user nums.

Let me know, thanks!

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - November 19, 2013 - edited: January 3, 2014

Hi Dave,

Thanks for coming to my rescue again.

This is actually on the same  site that you just recently looked at. I used "articles" because I thought it was an easier concept to explain.

There are about 2500 possible "articles" (listings) and about 1600 user members. There are 3 membership categories possible for each user.

I can't say how many will ultimately be members in good standing (not hidden) and how many won't, but their listings and accounts never get deleted.

Hope that's the information you were looking for.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - November 20, 2013 - edited: November 20, 2013

Hi Dave,

That's just what I needed.

I used the last suggestion in the load records call, like this: (adding the requirement of the "status" field having the value "available")

 <?php // load records from 'lm_listing'
  list($lm_listingRecords, $lm_listingMetaData) = getRecords(array(
    'tableName'   => 'lm_listing',
    'loadUploads' => true,
     'where' => " createdByUserNum IN (SELECT num FROM cms_accounts WHERE internal_notes LIKE '%12.%') AND status = 'Available' ", ",
    'perPage' => $maximages,
  ));
 ?>

And it seems to work perfectly.

Thanks again,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php