Last active
December 17, 2025 13:23
-
-
Save Asikur22/0f7a15b37e0286dfe4eee03b91da9c32 to your computer and use it in GitHub Desktop.
Create a User Registration Form in Elementor
This file contains hidden or 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
| /* | |
| * Create new user from Elementor form | |
| */ | |
| add_action( 'elementor_pro/forms/new_record', 'gl_elementor_form_create_new_user', 99, 2 ); | |
| function gl_elementor_form_create_new_user( $record, $ajax_handler ) { | |
| $form_id = $record->get_form_settings( 'id' ); | |
| if ( 'register_form' !== $form_id ) { | |
| return; | |
| } | |
| $raw_fields = $record->get( 'fields' ); | |
| $fields = []; | |
| foreach ( $raw_fields as $id => $field ) { | |
| $fields[ $id ] = $field['value']; | |
| } | |
| $email = $fields['email']; | |
| $password = $fields['password']; | |
| $user = wp_create_user( $email, $password, $email ); | |
| if ( is_wp_error( $user ) ) { | |
| $ajax_handler->add_error_message( "Failed to create new user: " . $user->get_error_message() ); | |
| $ajax_handler->is_success = false; | |
| return; | |
| } | |
| $first_name = $fields['first_name']; | |
| $last_name = $fields['last_name']; | |
| $phone = $fields['phone']; | |
| wp_update_user( array( | |
| "ID" => $user, | |
| "first_name" => $first_name, | |
| "last_name" => $last_name | |
| ) ); | |
| update_user_meta( $user->ID, 'phone', $phone ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment