Support

Account

Home Forums General Issues Get `user_role` checkbox keys and values

Solving

Get `user_role` checkbox keys and values

  • I created a field group for a specific user_role and a checkbox type field, such as:

    
            'fields' => array(
              array(
                'key' => 'field_member_options',
                'label' => 'Member Options',
                'name' => 'member_options',
                'type' => 'checkbox',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => array(
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
                'choices' => array(
                  0 => 'option 1',
                  1 => 'option 2',
                  2 => 'option 3',
                  3 => 'option 4',
                ),
                'allow_custom' => 0,
                'default_value' => array(
                ),
                'layout' => 'vertical',
                'toggle' => 0,
                'return_format' => 'array',
                'save_custom' => 0,
              ),
            ),
            'location' => array(
              array(
                array(
                  'param' => 'user_role',
                  'operator' => '==',
                  'value' => 'members',
                ),
              ),
            ),
    

    How can I get the keys and values of the checkbox field? Basically I need them in JSON format to display on a form, without a user of that role being logged in.

  • Thanks for the code, really appreciated your hard work.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Get `user_role` checkbox keys and values’ is closed to new replies.