Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't really know how to explain this, so this will most probably not make much sense.

Basically, I made a custom field (drop-down selection) for the Add/Edit User page, and I want to be the only one who can edit this. Like... when users go to the Edit User page, they can change the value of this field, which I don't want them to be able to do. I would at least like this field to be invisible to them, but not completely disappear, as I still do need this field.

share|improve this question

2 Answers 2

If you are the only "Administrator" and the rest of the users is lower level roles it is possible to achieve this. ACF has the option to set a rule to only display it based on user role.

Under "Edit Field Group" (where you setup the fields) there is a tab called "Location" where this is set (see the attached screenshot).

ACF rules - Only display for administrators

share|improve this answer
    
I know about this. Ah, it's really hard to explain what I mean. Like... I want it to be there for every single user, but I don't want them to be able to edit it. –  Alanea Mar 21 '13 at 10:42
    
You're not talking about read-only, are you? If so, you either set the attribute in ACF (if you can, that is), or you could add the attribute by means of jQuery. –  t f Mar 21 '13 at 15:21
    
I guess so. Or it can be hidden from them, but no from me (on their profile). As long as they aren't able to touch it. –  Alanea Mar 22 '13 at 1:52

Well, you could just check the current_user_id and depending on that set the field to hidden with the default value, or to the select with all the values you want to provide (to you).

// Edit

Short example:

<?php if (YOUR_ID === get_current_user_id()) : ?>
    <select id="UNIQUE_FIELD_NAME" name="UNIQUE_FIELD_NAME" value="whatever">
        <option>A</option>
        <option>B</option>
    </select>
<?php else : ?>
    <input type="hidden" id="UNIQUE_FIELD_NAME" name="UNIQUE_FIELD_NAME" value="whatever" />
<?php endif; ?>
share|improve this answer
    
Problem with this is that the Advanced Custom Fields plugin doesn't really give you the option to edit the output of the fields directly like this. –  jzatt Mar 21 '13 at 9:25
1  
@jzatt Yes, I was assuming this, after I read your answer. You wouldn't go that way of restricting the per user question to a per role answer if there were any other way, right? If so, please just live your life as if there were no answer from me. :) –  t f Mar 21 '13 at 9:28
    
Um, I don't understand. Where do I put this, exactly? Sorry, I'm a complete noob at this. –  Alanea Mar 21 '13 at 10:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.