How to create an advanced user registration form in WordPress, you need to add a phone number and gender, in which file to do this?, layout finished in the file
WP-LOGIN.PHP? But what to do next, how to add fields to the table, etc., how to save them there? And so that these fields are displayed parallelly in the WP admin. Thanks for the answer)
Answer 1, Authority 100%
correct the kernel files can not!
Registration is very simple:
Create a
form
& lt; div class = "registration" & gt;
& lt; Form Action = "" Method = "POST" & GT;
& lt;? PHP WP_NONCE_FIELD ('Registration', 'Registration_nonce')? & GT;
& lt; Input Type = "text" name = "username" required = "required" / & gt;
& lt; Input Type = "Password" name = "password" required = "required" / & gt;
& lt; Input Type = "Email" name = "email" required = "Required" / & gt;
& lt; Input Type = "Tel" name = "phone" required = "required" / & gt;
& lt; Input Type = "Submit" value = "Registration" & gt;
& lt; / form & gt;
& lt; / div & gt;
process it
add_action ('WP', 'Registration');
Function Registration () {
$ nonce = filter_input (input_post, 'registration_nonce', filter_sanitize_string);
If (! WP_VERIFY_NONCE ($ NONCE, 'REGISTRATION')) {
Return;
}
$ username = filter_input (input_post, 'username', filter_sanitize_string);
$ password = filter_input (input_post, 'password', filter_sanitize_string);
$ email = filter_input (input_post, 'email', filter_sanitize_email);
$ Phone = Filter_Input (Input_Post, 'Phone', Filter_Sanitize_String);
// Validate Fields ...
$ user = WP_CREATE_USER ($ username, $ password, $ email);
If (! IS_WP_ERROR ($ User)) {
update_user_meta ($ User, 'Phone', $ Phone); // Keep extra. field
WP_SET_AUTH_COOKIE ($ User, True); // Authorizing the user
$ URI = Filter_Input (Input_Server, 'Request_uri', filter_sanitize_string);
WP_SAFE_REDIRECT ($ URI, 302); // redirect after entering the page
}
}
List on the list of all users add. Information:
add_filter ('manage_candidate_posts_columns', 'register_column');
Add_action ('manage_candidate_posts_custom_column', 'column_callback');
FUNCTION REGISTER_COLUMN (Array $ Columns): Array {
Return Array_Slice ($ columns, 0, 4) + ['Phone' = & gt; 'Phone] + Array_Slice ($ columns, 4);
}
Function Column_Callback (String $ Output, String $ Column_Name, Int $ User_ID): String {
if ('Phone' === $ column_name) {
$ Phone = Get_user_Meta ($ user_id, 'Phone', True);
$ Output = '& lt; a href = "tel:'. $ Phone. '" & Gt;' . $ Phone. '& Lt; / a & gt;';
}
return $ output;
}