Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////adapted from: https://support.metabox.io/topic/mb_user_profile_register-autocompletenew-password/
- //relevant docs: https://docs.metabox.io/extensions/mb-user-profile/#form-fields-filters
- function add_more_registration_fields( $fields ) {
- $fields = [
- 'username' => [
- 'name' => __( 'Username', 'mb-user-profile' ),
- 'id' => 'user_login',
- 'type' => 'text',
- 'required' => true,
- 'columns' => 6,
- ],
- 'email' => [
- 'name' => __( 'Email', 'mb-user-profile' ),
- 'id' => 'user_email',
- 'type' => 'email',
- 'required' => true,
- 'columns' => 6,
- 'desc' => 'Used for account notifications and alerts (if opted-in).',
- ],
- 'password' => [
- 'name' => __( 'Password', 'mb-user-profile' ),
- 'id' => 'user_pass',
- 'type' => 'password',
- 'required' => true,
- 'columns' => 6,
- 'password_strength' => 'medium',
- 'desc' => 'Choose a password with a strength of <b>Medium</b> or higher. <br><span id="password-strength" class="rwmb-password-strength"></span>',
- 'attributes' => [
- 'autocomplete' => 'new-password'
- ]
- ],
- 'password2' => [
- 'name' => __( 'Confirm Password', 'mb-user-profile' ),
- 'id' => 'user_pass2',
- 'type' => 'password',
- 'required' => true,
- 'password_strength' => 'medium',
- 'columns' => 6,
- ],
- // ... add more fields here
- ];
- return $fields;
- }
- add_filter( 'rwmb_profile_register_fields', 'add_more_registration_fields' );
- //add this to the edit profile too
- ////https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields
- //These fields need to be added this way instead of in the function preceding this one.
- //See: https://support.metabox.io/topic/how-to-modify-deafult-fields-specifically-on-front-end-user-registration-form/#post-36704
- add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
- $meta_boxes[] = [
- 'title' => 'Default Fields',
- 'id' => 'default-fields',
- 'type' => 'user',
- 'fields' => [
- [
- 'id' => 'first_name',
- 'name' => 'First Name',
- 'type' => 'text',
- 'required' => true,
- 'columns' => 4,
- ],
- [
- 'id' => 'last_name',
- 'name' => 'Last Name',
- 'type' => 'text',
- 'required' => true,
- 'columns' => 4,
- ],
- 'phonenumber' => [
- 'name' => __( 'Phone Number', 'mb-user-profile' ),
- 'id' => 'phonenumber',
- 'type' => 'tel',
- 'required' => true,
- 'desc' => 'Used for notifications and alerts (if opted-in).',
- 'columns' => 4,
- //'mask' => '(999) 999-9999'
- ],
- /* [
- 'id' => 'display_name',
- 'name' => 'Display Name',
- 'type' => 'text',
- ],
- [
- 'id' => 'description',
- 'name' => 'Biography',
- 'type' => 'textarea',
- ],*/
- ],
- 'validation' => [
- 'rules' => [
- 'phonenumber' => [
- 'phoneUS' => true,
- //'minlength' => 7,
- ],
- // Rules for other fields
- ],
- 'messages' => [
- 'phonenumber' => [
- 'phoneUS' => "Please enter a valid US phone number.
- <br><b>Examples:</b>
- <ul>
- <li>5555555555</li>
- <li>(555) 555-5555</li>
- <li>555-555-5555</li>
- </ul>"
- ],
- // Error messages for other fields
- ],
- ],
- ];
- return $meta_boxes;
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement