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