public/wordpress/wp-content/plugins/wp-courseware/includes/controllers/checkout.php
/**
	 * Create a new student account if needed.
	 *
	 * @since 4.3.0
	 *
	 * @param array $data The posted data.
	 */
Create a new student account if needed.

@param array $data The posted data.
Create a new student account if needed . @param array $data The posted data .
protected function process_student( $data ) {
		$student_id = apply_filters( 'wpcw_checkout_student_id', get_current_user_id() );
		if ( ! is_user_logged_in() ) {
			$username   = ! empty( $data['account_username'] ) ? $data['account_username'] : '';
			$password   = ! empty( $data['account_password'] ) ? $data['account_password'] : '';
			$student_id = wpcw_create_new_student( $data['email'], $username, $password );
			if ( is_wp_error( $student_id ) ) {
				throw new Exception( $student_id->get_error_message() );
			}
			wp_set_current_user( $student_id );
			wpcw_set_student_auth_cookie( $student_id );
		}
		if ( $student_id && is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() ) {
			add_user_to_blog( get_current_blog_id(), $student_id, 'subscriber' );
		}
		if ( $student_id && apply_filters( 'wpcw_checkout_update_student_data', true, $this ) ) {
			$student = new Student( $student_id );
			if ( ! empty( $data['first_name'] ) ) {
				$student->set_prop( 'first_name', esc_attr( $data['first_name'] ) );
			}
			if ( ! empty( $data['last_name'] ) ) {
				$student->set_prop( 'last_name', esc_attr( $data['last_name'] ) );
			}
			if ( ( ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) ) || is_email( $student->get_display_name() ) ) {
				$student->set_prop( 'display_name', esc_attr( $data['first_name'] ) . ' ' . esc_attr( $data['last_name'] ) );
			}
			foreach ( $data as $key => $value ) {
				$student->set_prop( $key, $value );
			}
			if ( ! empty( $data['terms'] ) ) {
				$student->update_meta( '_wpcw_agree_to_terms_time', date_i18n( 'Y-m-d H:i:s' ) );
			}
			if ( ( 'yes' === wpcw_get_setting( 'privacy_policy' ) ) && ! empty( $data['privacy'] ) ) {
				$student->update_meta( '_wpcw_agree_to_privacy_policy_time', date_i18n( 'Y-m-d H:i:s' ) );
			}
			do_action( 'wpcw_checkout_update_student', $student, $data );
			$student->save();
		}
	}
protected function process_student ( $ data ) { $ student_id = apply_filters ( 'wpcw_checkout_student_id' , get_current_user_id ( ) ) ; if ( ! is_user_logged_in ( ) ) { $ username = ! empty ( $ data [ 'account_username' ] ) ? $ data [ 'account_username' ] : '' ; $ password = ! empty ( $ data [ 'account_password' ] ) ? $ data [ 'account_password' ] : '' ; $ student_id = wpcw_create_new_student ( $ data [ 'email' ] , $ username , $ password ) ; if ( is_wp_error ( $ student_id ) ) { throw new Exception ( $ student_id -> get_error_message ( ) ) ; } wp_set_current_user ( $ student_id ) ; wpcw_set_student_auth_cookie ( $ student_id ) ; } if ( $ student_id && is_multisite ( ) && is_user_logged_in ( ) && ! is_user_member_of_blog ( ) ) { add_user_to_blog ( get_current_blog_id ( ) , $ student_id , 'subscriber' ) ; } if ( $ student_id && apply_filters ( 'wpcw_checkout_update_student_data' , true , $ this ) ) { $ student = new Student ( $ student_id ) ; if ( ! empty ( $ data [ 'first_name' ] ) ) { $ student -> set_prop ( 'first_name' , esc_attr ( $ data [ 'first_name' ] ) ) ; } if ( ! empty ( $ data [ 'last_name' ] ) ) { $ student -> set_prop ( 'last_name' , esc_attr ( $ data [ 'last_name' ] ) ) ; } if ( ( ! empty ( $ data [ 'first_name' ] ) && ! empty ( $ data [ 'last_name' ] ) ) || is_email ( $ student -> get_display_name ( ) ) ) { $ student -> set_prop ( 'display_name' , esc_attr ( $ data [ 'first_name' ] ) . ' ' . esc_attr ( $ data [ 'last_name' ] ) ) ; } foreach ( $ data as $ key => $ value ) { $ student -> set_prop ( $ key , $ value ) ; } if ( ! empty ( $ data [ 'terms' ] ) ) { $ student -> update_meta ( '_wpcw_agree_to_terms_time' , date_i18n ( 'Y-m-d H:i:s' ) ) ; } if ( ( 'yes' === wpcw_get_setting ( 'privacy_policy' ) ) && ! empty ( $ data [ 'privacy' ] ) ) { $ student -> update_meta ( '_wpcw_agree_to_privacy_policy_time' , date_i18n ( 'Y-m-d H:i:s' ) ) ; } do_action ( 'wpcw_checkout_update_student' , $ student , $ data ) ; $ student -> save ( ) ; } }
Create a new student account if needed.
Create a new student account if needed .
// On multisite, ensure user exists on current site, if not add them before allowing login. // Add customer info from other fields. // If the display name is an email, update to the user's full name. /**
			 * Action: Checkout Update Student.
			 *
			 * @since 4.3.0
			 *
			 * @param Student The student object.
			 * @param array The posted data.
			 */