field switch to disabled unless the correct logged in user

How to disable a form field for non-admin users.

Overview

The issue occurs when a form field should only be editable by a specific logged-in user, such as an admin.
Add a condition in the form's extra parameters to check the current username and output the disabled attribute if it does not match the required user.

Answered
To Torák 05 Aug, 2014
Hello, sorry for the English, for it may uncle google.
My problem is that I have a form which needs one field "CHECK" switch to disabled unless the correct logged in user. Thank you David
Max_admin Max_admin 09 Aug, 2014
Answer
Hi David,

Please try this code in the "Extra params" box:

<?php
$user = JFactory::getUser();
if(!$user->get("id")){
echo 'disabled="disabled"';
}


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
To Torák 10 Aug, 2014
Thanks so much for your advice, it works perfectly. I modified it a bit.
<?php
      $user = &JFactory::getUser();
      $uzivatel = $user->username;
      if($uzivatel != "admin"){
      echo 'disabled="disabled"';
}
This topic is locked and no more replies can be posted.