ninja_forms_user_info_fields_groups

Function that adds the address group dropdown to the user information field items.

Description

ninja_forms_user_info_fields_groups( $field_id, $field_data ); 

Parameters (2)

0. $field_id
The field id.
1. $field_data
The field data.

Usage

  1. if ( !function_exists( 'ninja_forms_user_info_fields_groups' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/edit-field/user-info-fields.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The field data. 
  8. $field_data = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_user_info_fields_groups($field_id, $field_data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/edit-field/user-info-fields.php  
  1. function ninja_forms_user_info_fields_groups( $field_id, $field_data ) { 
  2. global $ninja_forms_fields; 
  3. $field = ninja_forms_get_field_by_id( $field_id ); 
  4. $field_type = $field['type']; 
  5. $default_user_info = 0; 
  6. if ( isset ( $ninja_forms_fields[$field_type]['edit_options'] ) and is_array( $ninja_forms_fields[$field_type]['edit_options'] ) ) { 
  7. foreach ( $ninja_forms_fields[$field_type]['edit_options'] as $option ) { 
  8. if ( isset ( $option['name'] ) and $option['name'] == 'user_info_field_group' and isset ( $option['default'] ) ) { 
  9. $default_user_info = $option['default']; 
  10. break; 
  11.  
  12. if ( ( isset ( $field_data['user_info_field_group'] ) AND $field_data['user_info_field_group'] == 1 ) or ( ( !isset ( $field_data['user_info_field_group'] ) or $field_data['user_info_field_group'] !== 0 ) and $default_user_info == 1 ) ) { 
  13. $options = array( 
  14. array( 'name' => '- '.__( 'None', 'ninja-forms' ), 'value' => '' ),  
  15. array( 'name' => __( 'Billing', 'ninja-forms' ), 'value' => 'billing' ),  
  16. array( 'name' => __( 'Shipping', 'ninja-forms' ), 'value' => 'shipping' ),  
  17. array( 'name' => __( 'Custom', 'ninja-forms' ).' ->', 'value' => 'custom' ),  
  18. ); 
  19.  
  20. if ( isset ( $field_data['user_info_field_group_name'] ) ) { 
  21. $group_name = $field_data['user_info_field_group_name']; 
  22. } else {  
  23. $group_name = ''; 
  24.  
  25. if ( isset ( $field_data['user_info_field_group_custom'] ) ) { 
  26. $group_custom = $field_data['user_info_field_group_custom']; 
  27. } else { 
  28. $group_custom = ''; 
  29.  
  30. if ( $group_name == 'custom' ) { 
  31. $custom_class = ''; 
  32. } else { 
  33. $custom_class = 'hidden'; 
  34.  
  35. ninja_forms_edit_field_el_output( $field_id, 'select', __( 'User Info Field Group', 'ninja-forms' ), 'user_info_field_group_name', $group_name, 'thin', $options, 'user-info-group-name widefat' ); 
  36. ninja_forms_edit_field_el_output( $field_id, 'text', __( 'Custom Field Group', 'ninja-forms' ), 'user_info_field_group_custom', $group_custom, 'thin', '', 'user-info-custom-group widefat '.$custom_class, '', $custom_class );