function rpx_login_form() { if (rpx_allow_wplogin() === false) { return false; } global $rpx_http_vars; if (is_user_logged_in()) { return true; } if ($rpx_http_vars['action'] == 'register') { if (rpx_allow_register() === false) { return false; } $logreg = RPX_OR_REGISTER_PROMPT; } else { $logreg = RPX_OR_LOGIN_PROMPT; } rpx_print_messages(); if (strstr(wp_login_url(), 'wp-login.php') !== false) { rpx_wp_footer(); } echo rpx_buttons(RPX_BUTTONS_STYLE_LARGE, $logreg); }
function rpx_test_wp_user() { global $rpx_wp_profile; global $rpx_http_vars; $tests = array(); rpx_message('user processing begin', 'debug'); /*The tests all assume this is an Engage auth so the id is required.*/ if (empty($rpx_wp_profile['rpx_identifier'])) { rpx_message('Empty identifier.', 'error'); return 'error'; } /*Skip tests if this is a data collect run.*/ if ($rpx_http_vars['action'] == RPX_DATA_MODE_ACTION) { return RPX_DATA_MODE_ACTION; } /*Sequential state tests, boolean*/ $allow_login = rpx_allow_signin(); $tests['allow_login'] = $allow_login; $user_data = rpx_user_data(); if ($user_data === false) { $active_user = false; } else { $active_user = true; } $tests['active_user'] = $active_user; if (empty($rpx_wp_profile['rpx_wp_id'])) { if (rpx_get_wpid() === true) { $rpx_match = true; rpx_get_meta(); } else { $rpx_match = false; } } else { if ($rpx_wp_profile['rpx_wp_id'] > 1 && $rpx_wp_profile['rpx_wp_id'] != '1') { $rpx_match = true; rpx_get_meta(); } else { $rpx_match = false; } } $tests['rpx_match'] = $rpx_match; if (empty($rpx_wp_profile['rpx_locked'])) { if ($rpx_match === false) { $rpx_wp_profile['rpx_locked'] = false; } else { $rpx_wp_profile['rpx_locked'] = true; } } if ($rpx_wp_profile['rpx_locked'] == 'true') { $rpx_locked = true; } else { $rpx_wp_profile['rpx_locked'] = 'false'; $rpx_locked = false; } $tests['rpx_locked'] = $rpx_locked; if (empty($rpx_wp_profile['rpx_verifiedEmail'])) { $rpx_verified_email = false; if (empty($rpx_wp_profile['rpx_email'])) { $rpx_email = false; } else { $rpx_email = true; } } else { $rpx_verified_email = true; $rpx_email = true; } $tests['rpx_verified_email'] = $rpx_verified_email; $tests['rpx_email'] = $rpx_email; if (empty($rpx_wp_profile['rpx_username'])) { $rpx_wp_profile['rpx_username'] = ''; } if (strlen(strip_tags($rpx_wp_profile['rpx_username'])) > 1) { $rpx_username = true; $rpx_wp_username_id = username_exists($rpx_wp_profile['rpx_username']); if ($rpx_wp_username_id === false || $rpx_wp_username_id === NULL) { //Ok who ruturns NULL? Seriously! $username_match = false; } else { $username_match = true; } } else { $rpx_username = false; $username_match = false; } $tests['rpx_username'] = $rpx_username; $tests['username_match'] = $username_match; $email_match = false; if (strlen(strip_tags($rpx_wp_profile['rpx_email'])) > 5) { $wp_email_id = email_exists($rpx_wp_profile['rpx_email']); if ($wp_email_id != false) { $email_found = true; $rpx_wp_profile['user_email'] = $rpx_wp_profile['rpx_email']; if (!empty($rpx_wp_profile['rpx_wp_id'])) { if ($rpx_wp_profile['rpx_wp_id'] == $wp_email_id) { $email_match = true; } } } else { $email_found = false; } } else { $email_found = false; } $tests['email_found'] = $email_found; $tests['email_match'] = $email_match; $wptest = rpx_validate_user(); if ($wptest === false) { $rpx_valid = false; } else { $rpx_valid = true; } $tests['rpx_valid'] = $rpx_valid; if (rpx_allow_register() === true) { $autoreg = true; } else { $autoreg = false; } $tests['autoreg'] = $autoreg; if (RPX_COLLECT_EMAIL == 'true') { $rpx_collect = true; } else { $rpx_collect = false; } $tests['rpx_collect'] = $rpx_collect; /*End of sequential tests*/ //var_dump($tests); exit;//expert debug point /*Sequential conditions for action*/ if ($allow_login === true && $rpx_match === true && $rpx_locked === false) { return 'signon'; } if ($allow_login === true && $active_user === true && $rpx_locked === false) { return 'engage'; } if ($allow_login === true && $autoreg === true && $rpx_collect === false && $rpx_locked === true && $rpx_match === true && ($rpx_email === false || $email_found === true)) { return 'skiplock'; } if ($allow_login === true && $rpx_match === true && $rpx_locked === true && ($rpx_email === false || $email_found === true || $rpx_valid === false)) { return 'retryemail'; } if ($allow_login === true && $rpx_match === true && $rpx_locked === true && $rpx_email === true && $email_found === false) { return 'register'; } if ($allow_login === true && $email_found === true && $rpx_verified_email === true && $rpx_locked === false && get_option(RPX_VEMAIL_OPTION) == 'true') { return 'vemail'; } if ($allow_login === true && $autoreg === true && $rpx_match === false && $rpx_email === true && $email_found === false && $rpx_username === true && $username_match === false) { return 'create'; } if ($allow_login === true && $autoreg === false && $rpx_match === false) { return 'regdirect'; } if ($allow_login === true && $autoreg === true && $rpx_match === false && ($rpx_username === false || $username_match === true)) { return 'getuser'; } if ($allow_login === true && $autoreg === true && $rpx_match === false && $rpx_collect === false && ($rpx_email === false || $email_found === true)) { return 'skipemail'; } if ($allow_login === true && $autoreg === true && $rpx_match === false && $rpx_collect === true && ($rpx_email === false || $email_found === true)) { return 'getemail'; } /*Conditions for error action*/ if ($email_found === true) { rpx_message('The email address ' . $rpx_wp_profile['rpx_email'] . ' is already registered with another account.', 'message'); } if ($rpx_match === true && $rpx_locked === true && $email_found === false) { rpx_message('Session ID does not match. Unable to unlock unverified account. Contact site admin to reset the account for "' . $rpx_wp_profile['rpx_username'] . '"', 'message'); } rpx_message('user processing end', 'debug'); return 'error'; }