How to add custom field to wordpress register form
-
I’m using a pre-built registration form for new users to sign up to a website. I want to be able to add two fields to the form so that users can input their first name and last name to the form, and that will then display in the user dashboard in the back-end of the website.
Heres the php code as it stands: I’ve added the fields to the form, but I’m getting an issue where even though first name and surname are being submitted, they aren’t appearing in the user’s account in the dashboard.
Thanks,
Gpublic static function init_fields() {
self::$fields = apply_filters( ‘register_form_fields’, array(
‘creds’ => array(
‘nicename’ => array(
‘label’ => __( ‘Username’, ‘jobify’ ),
‘type’ => ‘text’,
‘required’ => true,
‘placeholder’ => ”,
‘priority’ => 1
),
‘first_name’ => array(
‘label’ => __( ‘First Name’, ‘jobify’ ),
‘type’ => ‘text’,
‘required’ => true,
‘placeholder’ => ”,
‘priority’ => 2
),
‘last_name’ => array(
‘label’ => __( ‘Surname’, ‘jobify’ ),
‘type’ => ‘text’,
‘required’ => true,
‘placeholder’ => ”,
‘priority’ => 3
),
’email’ => array(
‘label’ => __( ‘Email Address’, ‘jobify’ ),
‘type’ => ‘text’,
‘required’ => true,
‘placeholder’ => __( ’[email protected]’, ‘jobify’ ),
‘priority’ => 4
),
‘password’ => array(
‘label’ => __( ‘Password’, ‘jobify’ ),
‘type’ => ‘password’,
‘required’ => true,
‘placeholder’ => ”,
‘priority’ => 5
)
),
‘info’ => array(
‘role’ => array(
‘label’ => __( ‘About You’, ‘jobify’ ),
‘type’ => ‘select’,
‘required’ => true,
‘priority’ => 6,
‘options’ => array(
‘none’ => __( ‘—Select—’, ‘jobify’ ),
’employer’ => __( ‘I'm an employer looking to hire’, ‘jobify’ ),
‘candidate’ => __( ‘I'm a paralegal applying for jobs’, ‘jobify’ )
)
)
)
) );
}
- The topic ‘How to add custom field to wordpress register form’ is closed to new replies.