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(); }
public function getForm() { $strMaxLength = "Your input is too long. Maximum length is %s"; $strMinLength = "Your input is too short. Minimum length is %s"; $strRequired = "This field is required."; $objForm = new ValidForm("installForm"); $objForm->setMainAlert("One or more errors occured. Check the marked fields and try again."); $objForm->addFieldset("CMS type", NULL, "PunchCMS can be installed for a single website or multiple websites at once."); $objForm->addField("single_instance", "Single website", VFORM_BOOLEAN); $objForm->addFieldset("Administrator settings", NULL, "This is the account for the admin area. Later you can create an admin per website."); $objForm->addField("username", "Username", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter only letters and spaces.")); $objForm->addField("passwd", "Password", VFORM_PASSWORD, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter only letters and numbers.")); $objForm->addField("email", "Email address", VFORM_EMAIL, array("maxLength" => 32, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Use the format name@domain.extension."), array("tip" => "This address will be used as the sender address for password reminders.")); $objForm->addFieldset("MySQL settings", NULL, "The database and user must already exist, otherwise the installation will fail."); $objForm->addField("db_server", "Server address", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the address of the MySQL server."), array("default" => "localhost")); $objForm->addField("db_name", "Database name", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the name of the designated database."), array("default" => "punchcms")); $objForm->addField("db_username", "Username", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the username for the database.")); $objForm->addField("db_passwd", "Password", VFORM_PASSWORD, array("maxLength" => 32, "required" => false), array("maxLength" => $strMaxLength, "type" => "Enter the password for the database.")); $objForm->setSubmitLabel("Submit"); return $objForm; }
<?php if (isset($errors) && is_wp_error($errors)) { ?> <div class="error"><p><?php echo implode("</p>\n<p>", $errors->get_error_messages()); ?> </p></div> <?php } ?> <div class="registration-wrapper" id="page-profile"> <?php $form = new ValidForm('your-profile', '', bum_get_permalink_profile()); $form->addField('email', 'Email', VFORM_EMAIL, array('required' => true), array('required' => 'You need an email.', 'type' => 'Email not valid.'), array('default' => esc_attr($profileuser->user_email))); if ($wp_http_referer) { $form->addField('wp_http_referer', '', VFORM_HIDDEN, array(), array(), array('default' => esc_url($wp_http_referer))); } $form->addField('from', '', VFORM_HIDDEN, array(), array(), array('default' => 'profile')); $form->addField('action', '', VFORM_HIDDEN, array(), array(), array('default' => 'update')); $form->addField('user_id', '', VFORM_HIDDEN, array(), array(), array('default' => $user->ID)); $form->addField('checkuser_id', '', VFORM_HIDDEN, array(), array(), array('default' => $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) { $fields = json_decode($fields->description); foreach ($fields as $field) { //get info
?> "><?php _e('Register'); ?> </a> <?php } ?> </p> <?php break; case 'login': default: $form = new ValidForm('loginform', '', bum_get_permalink_login()); $form->addField('log', 'Username', VFORM_STRING, array('required' => true), array('required' => 'You need a username.'), array('tip' => 'Usernames cannot be changed.')); $form->addField('pwd', 'Password', VFORM_PASSWORD, array('required' => true), array('required' => 'Enter your password.')); $remember = $form->addField('rememberme', '', VFORM_CHECK_LIST); $remember->addField('Remember Me', 'forever'); $form->setSubmitLabel("Login"); do_action('login_form'); if ($bum_interim_login) { $form->addField('interim-login', '', VFORM_HIDDEN, array(), array(), array('default' => '1')); } else { $form->addField('redirect_to', '', VFORM_HIDDEN, array(), array(), array('default' => esc_attr($bum_redirect_to))); } $form->addField('testcookie', '', VFORM_HIDDEN, array(), array(), array('default' => '1')); echo $form->toHtml(); if (!$bum_interim_login) { ?> <p id="nav">
<H2 class="registration-title"><?php echo ucwords($type); ?> </H2> <?php $form = new ValidForm('registerform', '', bum_get_permalink_registration()); $form->addField('user_login', 'Username', VFORM_STRING, array('required' => true), array('required' => 'You need a username.'), array('tip' => 'Usernames cannot be changed.')); $form->addField('user_email', 'Email', VFORM_EMAIL, array('required' => true), array('required' => 'You need an email.', 'type' => 'Email not valid.')); $form->addField('user_email1', 'Confirm Email', VFORM_EMAIL, array('required' => true), array('required' => 'You need an email.', 'type' => 'Email not valid.')); $form->addField('user_type', '', VFORM_HIDDEN, array(), array(), array('default' => $type)); /* * 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) { $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) {