AdminNotices.php
5 years ago
AjaxHandler.php
5 years ago
Autologin.php
5 years ago
BuddyPressBbPress.php
5 years ago
EditUserProfile.php
5 years ago
ExtensionManager.php
5 years ago
FileUploader.php
5 years ago
FormPreviewHandler.php
5 years ago
FormRepository.php
5 years ago
FormShortcodeDefaults.php
5 years ago
GDPR.php
5 years ago
GlobalSiteAccess.php
5 years ago
ImageUploader.php
5 years ago
LoginAuth.php
5 years ago
Miscellaneous.php
5 years ago
ModifyRedirectDefaultLinks.php
5 years ago
PPRESS_Session.php
5 years ago
PROFILEPRESS_sql.php
5 years ago
PasswordReset.php
5 years ago
ProfileUrlRewrite.php
5 years ago
RegistrationAuth.php
5 years ago
SendEmail.php
5 years ago
ShortcodeThemeFactory.php
5 years ago
UserAvatar.php
5 years ago
UserSignupLocationListingPage.php
5 years ago
UsernameEmailRestrictLogin.php
5 years ago
WelcomeEmailAfterSignup.php
5 years ago
default-email-template.php
5 years ago
index.php
5 years ago
Autologin.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Classes; |
| 4 | |
| 5 | class Autologin |
| 6 | { |
| 7 | public static function is_ajax() |
| 8 | { |
| 9 | return defined('DOING_AJAX') && DOING_AJAX; |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Initialize class |
| 14 | * |
| 15 | * @param int $user_id |
| 16 | * @param string $login_id |
| 17 | * @param string $redirect |
| 18 | * |
| 19 | * @return mixed |
| 20 | */ |
| 21 | public static function initialize($user_id, $login_id = '', $redirect = '') |
| 22 | { |
| 23 | if ( ! ppress_user_id_exist($user_id)) return; |
| 24 | |
| 25 | if (apply_filters('ppress_auto_login_before_signup_redirection', true)) { |
| 26 | do_action('ppress_before_auto_login', $login_id, $user_id); |
| 27 | |
| 28 | $set_login_cookie = apply_filters('ppress_auto_login_set_cookie', true); |
| 29 | |
| 30 | if ($set_login_cookie) { |
| 31 | |
| 32 | $secure_cookie = ''; |
| 33 | // If the user wants ssl but the session is not ssl, force a secure cookie. |
| 34 | if ( ! force_ssl_admin()) { |
| 35 | if (get_user_option('use_ssl', $user_id)) { |
| 36 | $secure_cookie = true; |
| 37 | force_ssl_admin(true); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN === true) { |
| 42 | $secure_cookie = true; |
| 43 | } |
| 44 | |
| 45 | wp_set_auth_cookie($user_id, true, $secure_cookie); |
| 46 | wp_set_current_user($user_id); |
| 47 | } |
| 48 | |
| 49 | do_action('ppress_before_auto_login_redirect', $login_id, $user_id); |
| 50 | } |
| 51 | |
| 52 | $login_redirect = ! empty($redirect) ? $redirect : ppress_login_redirect(); |
| 53 | |
| 54 | /** Setup a custom location for "auto login after registration" */ |
| 55 | $login_redirection = apply_filters('ppress_auto_login_redirection', $login_redirect, $login_id, $user_id); |
| 56 | |
| 57 | if (self::is_ajax()) { |
| 58 | // we are returning array to uniquely identify redirect. |
| 59 | return [$login_redirection]; |
| 60 | } |
| 61 | |
| 62 | wp_safe_redirect($login_redirection); |
| 63 | exit; |
| 64 | } |
| 65 | |
| 66 | } |