Field visibility for users

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
nirvana
User
Posts: 41

Field visibility for users

Post by nirvana »

Hi there,

I'm trying to have a form in which there are certain field values which must only be set by admin like the "Publish on List" checkbox. Can it be done using phpmaker interface? If not, I will have to add the condition for each field by checking the currently logged in user's level.


nirvana
User
Posts: 41

Post by nirvana »

There are also auto-updated fields such as "last modified", "IP", "user id" which must be seen only by users having admin privilege. If I deselect view checkbox for these fields, all the users even admin cannot view them. Can we restrict the fields at the user level using the phpmaker interface or by writing additional scripts? Thank you.


YogiYang
User
Posts: 101

Post by YogiYang »

Refer to this topic I think it will answer your question.

http://www.hkvforums.com/viewtopic.php?f=4&t=44108


mobhar
User
Posts: 11741

Post by mobhar »

nirvana wrote:
Can we restrict the fields at the user level using the phpmaker interface or by writing additional scripts?

Yes, we can. To display or hide a field in a page based on current user level, you may simply use "Page_Load" server event, for example:

if (CurrentUserLevel() == "1") {
$this->YourFieldName->Visible = FALSE; // adjust YourFieldName to your actual field name
}


nirvana
User
Posts: 41

Post by nirvana »

Thanks a lot for your input! I was trying to edit the generated page using a similar logic. I will implement it into the project!


Post Reply