LLMS_Controller_Registration::register()

Handle submission of user registration forms


Return Return

(void)


Top ↑

Source Source

File: includes/forms/controllers/class.llms.controller.registration.php

	public function register() {

		if ( ! isset( $_REQUEST['_llms_register_person_nonce'] ) ) {
			return;
		}
		if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_llms_register_person_nonce'] ) ), 'llms_register_person' ) ) {
			return;
		}

		/**
		 * Allow 3rd parties to perform their own validation prior to standard validation.
		 *
		 * If this returns a truthy, we'll stop processing.
		 *
		 * The extension should add a notice in addition to returning the truthy.
		 *
		 * @since 7.8.0
		 *
		 * @param boolean $valid Validation status. If `true` ceases registration execution. If `false` registration proceeds.
		 */
		if ( apply_filters( 'llms_before_registration_validation', false ) ) {
			return false;
		}

		do_action( 'lifterlms_before_new_user_registration' );

		// Already logged in can't register!
		// This shouldn't happen but let's check anyway.
		if ( get_current_user_id() ) {
			return llms_add_notice( __( 'Already logged in! Please log out and try again.', 'lifterlms' ), 'error' );
		}

		$person_id = llms_register_user( $_POST, 'registration', true );

		// Validation or registration issues.
		if ( is_wp_error( $person_id ) ) {

			foreach ( $person_id->get_error_messages() as $msg ) {
				llms_add_notice( $msg, 'error' );
			}
			return;

		} elseif ( ! is_numeric( $person_id ) ) {

			// Catch unexpected returns from llms_register_user().
			return llms_add_notice( __( 'An unknown error occurred when attempting to create an account, please try again.', 'lifterlms' ), 'error' );

		} else {

			// Handle redirect.
			llms_redirect_and_exit( apply_filters( 'lifterlms_registration_redirect', llms_get_page_url( 'myaccount' ) ) );

		}
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.24.0 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.