filter list to show only current users options

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 28, 2013   (RSS)

Hi, 

To do this first you need to change the list fields 'list option' to 'Get options from MySQL query (advanced)'. This will allow you to add a custom MySQL statement to filter out only the agents you need. I think your code will need to look something like this:

SELECT num, name
  FROM `<?php echo $TABLE_PREFIX ?>agents`
 WHERE createdByUserNum = '<?php echo $CURRENT_USER['num']; ?>'

This is just example code, so you will need to change some of the variable names to get it to work with your sections.

The select line should contain the two fields you want to be used for the value and label of the field.

The from line should have the table you want to get your results from.

The where statement is checking the CMS Builder field createdByUserNum is equal to the current users num value, so it should only return results created by the current user.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com