RESTRICTING LIST VALUES TO AUTHORS ONLY - Apr 13th, 2016


On a site where I had employed the membership plugin, I was trying to set up a list that gets it’s options from the
“title” field of another table (your_source_table), using the “get options from mySQL query” option.

The trick was that I wanted to restrict the options that a member user can see to only those where they are the
option’s author, but as an administrator I would need to see them all.

Thanks to user Zip222, I came up with this solution.

First I set up a multi-record editor we'll call "your_source_table" with only one field called "title".

Next I created a list field in my 'receiving" editor and for the list values I chose the third option in the pull down
menu, "Get Options From MySQL Query (advanced)

I put the following code in the box to replace the dummy code that is there.

NOTE: The first entry in the SELECT determines the field from which the"Value" is returned (so that could be 'num',
which would return the record number, etc) and the second determines the Label that appears in the pull down list.



SELECT title, title

FROM <?php echo $TABLE_PREFIX ?>your_source_table_name
<?php if (!$CURRENT_USER['isAdmin']): ?>
<?php $where="WHERE createdByUserNum='".$CURRENT_USER['num']."'"; ?>
<?php echo $where ?>
<?php endif ?>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service