function bum_show_custom_fields_admin() { //get extra fields $profileuser = bum_get_user_to_edit($_GET['user_id']); if (!$profileuser->data->ID) { exit; } $fields = get_term_by('slug', $profileuser->roles[0], BUM_HIDDEN_FIELDS); $form = new ValidForm('your-profile', '', get_permalink() . '?user_id=' . $_GET['user_id']); /* * This handles extra fields ( basically reading the field info and putting it into ValidForm ) * Currently handles `radio`, `checkbox`, `select`, `input_text` ( text field ), and `textarea` */ if ($fields->description) { echo '<h3>Custom fields</h3>'; $fields = json_decode($fields->description); foreach ($fields as $field) { //get info $info = bum_get_field_info($field); $fid = 'bum_' . sanitize_title($info['title']); //this is handling `radio`, `checkbox`, `select` if (in_array($info['cssClass'], array('radio', 'checkbox', 'select'))) { if ($info['cssClass'] == 'radio') { $type = VFORM_RADIO_LIST; } elseif ($info['cssClass'] == 'checkbox') { $type = VFORM_CHECK_LIST; } else { $type = VFORM_SELECT_LIST; } //Multiple values are seperated by | ( pipe ) if (strpos($info['meta_value'], '|') !== false) { $info['meta_value'] = explode('|', $info['meta_value']); } $box = $form->addField('bum_' . $info['id'], $info['title'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['title']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); foreach ($info['values'] as $checkbox) { $box->addField($checkbox->value, htmlentities($checkbox->value)); } } //this is handling `input_text`, `textarea` if (in_array($info['cssClass'], array('input_text', 'textarea'))) { if ($info['cssClass'] == 'input_text') { $type = VFORM_STRING; } else { $type = VFORM_TEXT; } $form->addField('bum_' . $info['id'], $info['values'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['values']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); } } } echo $form->toWpHtml(); }