Running ACF PRO on WordPress …
I have two user types on my site, a standard user and a gold user
I have a ACF radio field which has two options, say ‘standard’ and ‘gold’.
What I would like to do in the backend is for standard users this radio button is set to ‘standard’ and for gold it is by default set to ‘gold’.
I’ve set the default selection of this radio button to ‘standard’ so that sorts the standard users and what I would like to do for the gold is in my functions.php something like this
$user_access_level = current_user_can('gold');
if ( $user_access_level == true ){
// I've got the user level detection working so it's next bit I'm really interested in
'acf/name=user_radio' = gold
}
Is this something that would be possible? If someone can point me in the right direction I’d be hugely grateful!
N

I am not sure where this value is shown. Is this on the user edit page ?
If I understand correctly, I think you need to look into creating a filter with acf/load_value, which sets the value upon load.
Hey Bee
This is on the post creation admin screen – so by default depending on the user thats logged in and their role different values would be selected.
It might not be the most elegant code but I did come up with a solution for this one
$user_access_level = current_user_can('gold');
if ( $user_access_level == true ){
$field['choices'] = array('standard', 'gold');
$field['default_value'] = 1;
}

Been looking in to the acf/load_value filter – really helpful, thanks for recommending Beee 🙂
The topic ‘Set value of ACF on user role’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.