Created
April 26, 2022 16:58
-
-
Save hivepress/232ba63de5115a56dc21cd7f64c6e52f to your computer and use it in GitHub Desktop.
Add first and last name fields to the user registration form #hivepress #users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'hivepress/v1/forms/user_register', | |
function ( $form ) { | |
$form['fields'] = array_merge( | |
$form['fields'], | |
[ | |
'first_name' => [ | |
'required' => true, | |
'_order' => 1, | |
], | |
'last_name' => [ | |
'required' => true, | |
'_order' => 2, | |
], | |
] | |
); | |
return $form; | |
}, | |
100 | |
); | |
add_action( | |
'hivepress/v1/models/user/register', | |
function( $user_id, $values ) { | |
if ( isset( $values['first_name'] ) ) { | |
update_user_meta( $user_id, 'first_name', $values['first_name'] ); | |
} | |
if ( isset( $values['last_name'] ) ) { | |
update_user_meta( $user_id, 'last_name', $values['last_name'] ); | |
} | |
}, | |
10, | |
2 | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately there's no simple temporary fix, this has to be changed in the framework. If you require an attachment from vendors (those users who want to add listings), you can require an attachment via the vendor registration form