Viewing 1 reply thread
  • Author
    Posts
    • #6194
      mandelkind
      Member

      How do I conditionally hide a field based on the selected user role in the user edit form?

      I’ve added the following field, which should show/hide in regards of if the user role is ‘client’ or not:

      piklist(‘field’,array(
      ‘conditions’ => array(array(
      ‘field’ => ‘role’,
      ‘value’ => ‘client’,
      ‘reset’ => ‘false’
      )),
      ‘type’ => ‘group’,
      ‘field’ => ‘end_saldos’,
      ‘label’ => __( ‘End Saldos’, ‘toggle’ ),
      ‘add_more’ => true,
      ‘fields’ => array(array(
      ‘type’ => ‘datepicker’,
      ‘field’ => ‘end_date’,
      ‘label’ => __( ‘Date’, ‘toggle’ ),
      ‘columns’ => 4

      ), array(
      ‘type’ => ‘number’,
      ‘field’ => ‘end_saldo’,
      ‘label’ => __( ‘Saldo’, ‘toggle’ ),
      ‘columns’ => 8
      ))
      ));

    • #6201
      Steve
      Keymaster

      @mandelkind– You would need to create a hidden Piklist field named role, and pass the current users role to the that field.

      Does that make sense?

Viewing 1 reply thread
  • You must be logged in to reply to this topic.