Home › Forums › General Issues › User role selector › Reply To: User role selector
Use this :
if( function_exists(‘acf_add_local_field_group’) ):
acf_add_local_field_group(array(
‘key’ => ‘group_5f33968e2461e’,
‘title’ => ‘Champs Articles’,
‘fields’ => array(
array(
‘key’ => ‘field_5f33969714b2f’,
‘label’ => ‘Gestion des droits’,
‘name’ => ‘manage-role’,
‘type’ => ‘checkbox’,
‘instructions’ => ”,
‘required’ => 0,
‘conditional_logic’ => 0,
‘wrapper’ => array(
‘width’ => ”,
‘class’ => ”,
‘id’ => ”,
),
‘choices’ => get_roles(),
‘allow_custom’ => 0,
‘default_value’ => false,
‘layout’ => ‘vertical’,
‘toggle’ => 0,
‘return_format’ => ‘value’,
‘save_custom’ => 0,
),
),
‘location’ => array(
array(
array(
‘param’ => ‘post_type’,
‘operator’ => ‘==’,
‘value’ => ‘post’,
),
),
),
‘menu_order’ => 0,
‘position’ => ‘side’,
‘style’ => ‘default’,
‘label_placement’ => ‘left’,
‘instruction_placement’ => ‘label’,
‘hide_on_screen’ => ”,
‘active’ => true,
‘description’ => ”,
));
endif;
function get_roles() {
$wp_roles = new WP_Roles();
$roles = $wp_roles->get_names();
return $roles;
}
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.