PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/class-lp-checkout.php +22 -14 4.4.54.4.8 View file →
@@ -97,11 +97,18 @@
97 97 */
98 98 public function check_validate_fields() {
99 99 $session = LearnPress::instance()->session;
100 100 $data_session_before_user_login = $session->get_session_data();
101 - $checkout_account_type = LP_Request::get_param( 'checkout-account-switch-form' );
102 - $this->checkout_action = $checkout_account_type;
101 + $this->checkout_action = null;
103 102
103 + if ( isset( $_POST['reg_email'] ) ) {
104 + $this->checkout_action = 'register';
105 + } elseif ( isset( $_POST['username'] ) ) {
106 + $this->checkout_action = 'login';
107 + } elseif ( isset( $_POST['guest_email'] ) ) {
108 + $this->checkout_action = 'guest';
109 + }
110 +
104 111 switch ( $this->checkout_action ) {
105 112 case 'login':
106 113 $user = wp_signon(
107 114 array(
@@ -151,22 +158,23 @@
151 158
152 159 if ( is_wp_error( $user_id ) ) {
153 160 throw new Exception( $user_id->get_error_message() );
154 161 } else {
155 - $user = wp_signon(
156 - array(
157 - 'user_login' => $default_fields['reg_email'],
158 - 'user_password' => $default_fields['reg_password'],
159 - 'remember' => 1,
160 - ),
161 - is_ssl()
162 - );
162 + // Directly authenticate the newly created user to bypass captcha plugins
163 + // that hook into 'authenticate'. We already verified the password during registration.
164 + $user = get_user_by( 'id', $user_id );
163 165
164 - if ( is_wp_error( $user ) ) {
165 - throw new Exception( $user->get_error_message() );
166 - } else {
167 - wp_set_current_user( $user->ID );
166 + if ( ! $user instanceof WP_User ) {
167 + throw new Exception( __( 'User registration succeeded but the user cannot be loaded.', 'learnpress' ) );
168 168 }
169 +
170 + /*if ( ! wp_check_password( $default_fields['reg_password'], $user->user_pass, $user->ID ) ) {
171 + throw new Exception( __( 'Incorrect password.', 'learnpress' ) );
172 + }*/
173 +
174 + wp_set_current_user( $user->ID );
175 + wp_set_auth_cookie( $user->ID, true, is_ssl() );
176 + do_action( 'wp_login', $user->user_login, $user );
169 177 }
170 178 break;
171 179 case 'guest':
172 180 $email_guest = LP_Request::get_param( 'guest_email' );