Call: (209) 560-6611

How to create custom fields for users only admin can edit

Date: January 11, 2013 Author: ang Category: Tutorials Tags: , , Comments: 0

In this tutorial I will show you how to create custom fields for your WordPress website users that they will be able to read but not edit. Only the admin will be able to create and edit these fields. You will need a FTP connection to complete this tutorial.

Install this plugin that allows you to create custom user fields

First install Simple CRM. This plugin allows you to create custom fields for your user. The only fields you can create using this plugin are text input fields and text area fields.

Go ahead and read the plugin instructions create some custom fields.

Next I'm going to show you how you can modify a script in the 'Simple CRM' plugin to make the custom fields 'read only' for the users and yet still editable by the admin.

How to make custom user fields read only for the user but not the admin

    1. Connect via FTP to your WordPress website.
    2. Navigate to file wp-content > plugins > simple-cm > includes > templates > profile.php.
    3. Just after just after
       HTML |  copy code |? 
      1
      <input
      And
       HTML |  copy code |? 
      1
      <textarea
      insert the code snippet:
       PHP |  copy code |? 
      1
      <? if( current_user_can( 'administrator' ) ){}else{echo"readonly=\"readonly\"";} ?>
    4. Save the changes and upload the new file.Note: It's a good idea to backup the old file just in case. 

Now users will be able to read any custom fields you create using 'Simple CRM' but they won't be able to edit the fields. You can also edit these fields for the user when logged in as admin.

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

What has leaves, a trunk, and branches, and grows in forests?

Before you post, please prove you are sentient.

What is the outer covering of a tree?