function buatp_conditional_fields_by_type() { if (!$_POST['type']) { die; } $type_id = buatp_get_field_id_by_name($_POST['type']); $settings_profile_data = get_option('buatp_profile_data_setting', true); if (!$settings_profile_data['buatp_include_fields_at_registration_for_' . $type_id]) { die; } $arr = (array) $settings_profile_data['buatp_include_fields_at_registration_for_' . $type_id]; foreach ($arr as $names) { $includes_arr[$i++] = buatp_get_field_id_by_name($names); } $groups = buatp_get_all_field_groups(); foreach ($groups as $id) { $all_fields = array_merge((array) $all_fields, buatp_get_all_fields("WHERE group_id = {$id} AND parent_id = 0", 'id')); } foreach ((array) $all_fields as $f_id) { if (!in_array($f_id, $includes_arr)) { $excludes_arr[$j++] = $f_id; } } $excludes = implode(',', (array) $excludes_arr); $includes = implode(',', (array) $includes_arr); $groups_inc = implode(',', $groups); $html = '<div class="conditional_fields">'; foreach ($groups as $id) { $html .= buatp_generate_fields("profile_group_id={$id}&exclude_fields={$excludes}"); } $html .= "<input type='hidden' id='conditional_field_values' value='{$includes}' /> </div>"; echo $html; die; }
function buatp_get_all_select_box_fields() { global $wpdb; $query = "SELECT * FROM " . $wpdb->base_prefix . "bp_xprofile_fields WHERE type='selectbox'"; return buatp_get_all_fields("WHERE type='selectbox'"); }
function buatp_profile_data_setting_page() { $setting_fields = array(); if (count($this->buatp_basic_setting) < 4) { $setting_fields = array(array('name' => 'buatp_notice', 'label' => '', 'type' => 'html', 'value' => '<p class="buatp_notice">Please complete and save Basic Settings first to get more options</p>')); return $setting_fields; } $setting_fields = array(array('name' => 'buatp_exclude_types_to_select_own', 'class' => 'buatp_exclude_types_to_select_own', 'label' => __(sprintf('Exclude type selection from user'), 'buatp'), 'desc' => __(sprintf('You may limit type selection for users,excluded types will not visible to users, <br>so they cant change to this type themself,but admin can change'), 'buatp'), 'type' => 'multicheck', 'options' => $this->type_array, 'before' => '<div class="checkbox_container">', 'after' => '</div>')); foreach ((array) $this->all_type_info as $val) { $j++; if (count(buatp_get_all_profile_groups())) { $groupss_list[$j] = array('name' => 'buatp_exclude_groups_for_' . $val['id'], 'class' => 'buatp_exclude_groups_for_' . $val['id'], 'label' => __(sprintf('Exclude Profile groups for <strong>%1$s</strong> type users', $val['name']), 'buatp'), 'desc' => __(sprintf('<strong>%1$s</strong> type users can not access these excluded groups, All fields in these groups are not visible and not editable to users. <br>Admin can view and edit only <br> Default: none', $val['name']), 'buatp'), 'type' => 'multicheck', 'options' => buatp_get_all_profile_groups(), 'before' => '<div class="checkbox_container">', 'after' => '</div>'); } $fields_list[$j] = array('name' => 'buatp_exclude_fields_for_' . $val['id'], 'class' => 'buatp_exclude_fields_for_' . $val['id'], 'label' => __(sprintf('Exclude fields for <strong>%1$s</strong> type users', $val['name']), 'buatp'), 'desc' => __(sprintf('<strong>%1$s</strong> type users can not access these excluded fields from his/her buddypress profile', $val['name']), 'buatp'), 'type' => 'multicheck', 'options' => buatp_get_all_fields("WHERE parent_id = 0 AND ID!={$this->buatp_type_field_id}"), 'before' => '<div class="checkbox_container">', 'after' => '</div>'); $fields_list_reg[$j] = array('name' => 'buatp_include_fields_at_registration_for_' . $val['id'], 'class' => 'buatp_include_fields_at_registration_for_' . $val['id'], 'label' => __(sprintf('Include fields for <strong>%1$s</strong> type users at registration form', $val['name']), 'buatp'), 'desc' => __(sprintf('<strong>%1$s</strong> type users can fill up these included fields during registration. These fields will be shown after selecting type.', $val['name']), 'buatp'), 'type' => 'multicheck', 'options' => (array) $this->exclude_fields_array, 'before' => '<div class="checkbox_container">', 'after' => '</div>'); } $more_profile_data_fields = array(array('name' => 'buatp_fields_for_profile_loop', 'class' => 'buatp_fields_for_profile_loop', 'label' => __('Select fields to show in profile loop', 'buatp'), 'desc' => __(sprintf('You may add some fields to show in members directory beside the member\'s avatar. Demo:<br> <div id="buatp_members"><img class="demo_member" src="%1s" /></div>', BUATP_IMG_URI . 'loop-field-demo.png'), 'buatp'), 'type' => 'multicheck', 'options' => buatp_get_all_fields(), 'before' => '<div class="checkbox_container">', 'after' => '</div>'), array('name' => 'buatp_fields_for_profile_loop_per_column', 'class' => 'buatp_fields_for_profile_loop_per_column', 'label' => __('Number of fileds per column', 'buatp'), 'desc' => __('<br>How many fields you want to show in a column in members directory, default is 3, <br>column will increase automatically when fields available', 'buatp'), 'type' => 'text', 'default' => '3')); $setting_fields = array_merge($setting_fields, (array) $groupss_list, (array) $fields_list, (array) $fields_list_reg, $more_profile_data_fields); return $setting_fields; }