Home › Forums › Plugin Support › Read-Only for Non-Admin
- This topic has 8 replies, 5 voices, and was last updated 9 years, 9 months ago by adaldesign.
-
AuthorPosts
-
March 18, 2013 at 6:59 pm #3470March 18, 2013 at 7:24 pm #3472rogerrabbitMember
i could solve it. I added following code to the user-meta/views/generateField.php (Beginning Line 259)
elseif( $field[‘field_type’] == ‘radio’ ):
$fieldType = ‘radio’;
if( ! empty( $field[‘line_break’] ) ):
$option_after = “”;
endif;
/* added code ———————————————————————— */
if( $fieldReadOnly == ‘readonly’ ) :
$isDisabled = true;
endif;
/* end added code ———————————————————————— */March 19, 2013 at 3:17 pm #3489rogerrabbitMemberThis fix does not work as expected. Now the radio buttons are readonly but if the user press update profile, then it clears the readonly settings on the meta database.
March 23, 2013 at 12:17 am #3512neokraftMemberYes, I was also going to post about this issue; I want radio buttons,drop downs and some related fields not to be editable or even click-able; when a user that has read-only access logs in my opinion, they should only view those fields(drop down,checkbox,radio buttons) and not be able to make changes to them. Please help us find a lasting solution to this.
March 25, 2013 at 5:43 pm #3530SupportMemberHello, for version 1.1.3, please open user-meta/views/generateField.php
Then, add following line at line number 331
$isDisabled = !empty($fieldReadOnly) ? true : false;Thanks.
March 26, 2013 at 9:14 pm #3541neokraftMemberThanks a lot this did work.
April 5, 2013 at 3:23 am #3602uniqsitesMemberI have used the correction on 331 but am having the same issue as @rogerrabbit.
The checkboxes are readonly but if the user (Contributor level) updates their profile it clears the readonly settings. Is there a fix for this?April 5, 2013 at 6:55 am #3603uniqsitesMemberAfter some research here is what I discovered. Elements with the disabled attribute are not posted to the server. That explains why the values are cleared on a profile update. Elements with the readonly attribute are selectable but not editable by the user. Their values are posted to the server. However, select boxes and check boxes do not allow the readonly attribute.
My solution was to keep the elements disabled and alter the plug in code to insert a hidden field for each disabled field. For version 1.1.3, in user-meta/views/generateField.php, I inserted the following code on line 367. So far, it appears to be working.
if($isDisabled){
$html .= $userMeta->createInput( ($fieldType == "checkbox") ? $field['field_name']."[]" : $field['field_name'], "hidden",
array(
"value" => ($fieldType == "checkbox") ? $field['field_value'][0] : $field['field_value'],
"id" => $inputID,
"by_key" => $by_key,
), null );
}
February 8, 2015 at 8:29 pm #6777adaldesignMemberI am surprised that almost two years later this issue is this the same. I think I’ll hack a quick fix with jQuery for my own site, but it would be nice to see this solved for checkboxes in a clean way.
-
AuthorPosts
- You must be logged in to reply to this topic.