LLMS_Order_Generator::validate_user()

Validates the submitted user data.


Return Return

(boolean|WP_Error) Returns true on success or an error object.


Top ↑

Source Source

File: includes/class-llms-order-generator.php

	protected function validate_user() {

		$validate = llms_validate_user( $this->data );
		if ( is_wp_error( $validate ) ) {
			return $validate;
		}

		// If validation passes, determine if the user already exists and, if they do, validate their enrollment.
		$email = $this->data['email_address'] ?? null;
		$user  = $email ? get_user_by( 'email', $email ) : false;
		if ( $user && llms_is_user_enrolled( $user->ID, $this->plan->get( 'product_id' ) ) ) {
			return $this->error(
				self::E_USER_ENROLLED,
				sprintf(
					// Translators: %s = The title of the course or membership.
					__( 'You already have access to %s.', 'lifterlms' ),
					get_the_title( $this->plan->get( 'product_id' ) )
				)
			);
		}

		return true;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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