Adding User Value to field in back end

5 posts by 3 authors in: Forums > CMS Builder
Last Post: June 1, 2012   (RSS)

By pgplast - May 30, 2012

I am interested to know if there is a way to add a logged in user value into a field placed in a CMS builder table from within the backend. Rather than work with an outside form, I would like to allow a user "author" access to a blog posting table and automatically place the user's name or num into a field hidden to all but admins. It does not appear that one can place $CURRENT_USER['num'] or <?php echo $CURRENT_USER['num'] ?> into a text field as a default value. I tried to make a field using the relatedRecords choice, using the accounts table and where clause:

num='<?php echo mysql_escape(@$CURRENT_USER['num']) ?>'

This does generate a field of values from the accounts table that the admin can see, but I don't know how one would pluck out a name or num value for use in a viewer for those records. For example, if the field is named "bloggers," the use of echo $record['bloggers.fullname'] just throws an error.

Any suggestions>

Thanks.

Re: [pgplast] Adding User Value to field in back end

By Jason - May 31, 2012

Hi,

When a record is created, the user's num value gets stored in the createdByUserNum field of the record just created. When the record is retrieved on the front end, you can access user information through the createdBy. set of pseudo fields.

for example, to get their full name, you would output this:

<?php echo $record['createdBy.fullname'];?>

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] Adding User Value to field in back end

By pgplast - May 31, 2012

Thanks, Jason. That's exactly what I meant (and what I assumed you had already designed in). So createByUserNum is a foreign key for all user created tables.

The docs that IT provides general users of CMS Builder is helpful, but exposes little of the inner workings of the app for people trying to leverage its capabilities. Is there a plan to produce a site or updating document that details CMSB functions, plugin hooks, etc? -(I am glad for your code comments, but in many cases, a go-to source of more detail would be very helpful ;) . )

Re: [pgplast] Adding User Value to field in back end

By gkornbluth - June 1, 2012

Hi pgplast,

You might also find some of the information and recipes in my CMSB Cookbook helpful http://www.thecmsbcookbook.com

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