LLMS_Person_Handler::register( array $data = array(), string $screen = 'registration', bool $signon = true )
Perform validations according to the registration screen and registers a user
Contents
Description Description
See also See also
- llms_register_user(): for a classless wrapper for this function
Parameters Parameters
- $data
-
(array) (Optional) array of user data array( 'user_login' => '', 'email_address' => '', 'email_address_confirm' => '', 'password' => '', 'password_confirm' => '', 'first_name' => '', 'last_name' => '', 'llms_billing_address_1' => '', 'llms_billing_address_2' => '', 'llms_billing_city' => '', 'llms_billing_state' => '', 'llms_billing_zip' => '', 'llms_billing_country' => '', 'llms_phone' => '', )
Default value: array()
- $screen
-
(string) (Optional) screen to perform validations for, accepts "registration" or "checkout"
Default value: 'registration'
- $signon
-
(bool) (Optional) if true, also signon the newly created user
Default value: true
Return Return
(int|WP_Error)
Source Source
File: includes/class.llms.person.handler.php
public static function register( $data = array(), $screen = 'registration', $signon = true ) { do_action( 'lifterlms_before_user_registration', $data, $screen ); // generate a username if we're supposed to generate a username if ( llms_parse_bool( get_option( 'lifterlms_registration_generate_username' ) ) && ! empty( $data['email_address'] ) ) { $data['user_login'] = self::generate_username( $data['email_address'] ); } // validate the fields & allow custom validation to occur $valid = apply_filters( 'lifterlms_user_registration_data', self::validate_fields( $data, $screen ), $data, $screen ); // if errors found, return them if ( is_wp_error( $valid ) ) { return apply_filters( 'lifterlms_user_registration_errors', $valid, $data, $screen ); } else { do_action( 'lifterlms_user_registration_after_validation', $data, $screen ); // create the user and update all metadata $person_id = self::insert_data( $data, 'registration' ); // even during checkout we want to call this registration // return the error object if registration fails if ( is_wp_error( $person_id ) ) { return $person_id; // this is filtered already } // signon if ( $signon ) { llms_set_person_auth_cookie( $person_id, false ); } // fire actions do_action( 'lifterlms_created_person', $person_id, $data, $screen ); do_action( 'lifterlms_user_registered', $person_id, $data, $screen ); // return the ID return $person_id; } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: