PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 2.2.4
Wp Social Login and Register Social Counter v2.2.4
trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / inc / login.php
wp-social / inc Last commit date
elementor 3 years ago admin-create-shortcode.php 7 years ago admin-create-user.php 3 years ago admin-custom-function.php 3 years ago admin-rest-api.php 4 years ago admin-settings.php 3 years ago admin-social-button.php 3 years ago admin-social-enque-script.php 5 years ago counter-widget.php 3 years ago counter.php 3 years ago custom-function.php 4 years ago login-widget.php 3 years ago login.php 5 years ago share-widget.php 3 years ago share.php 3 years ago
login.php
125 lines
1 <?php
2
3 namespace WP_Social\Inc;
4
5 /**
6 * Login functionality for social logins
7 *
8 */
9
10 defined('ABSPATH') || exit;
11
12 class Login {
13
14 /**
15 * ===================
16 * Singleton
17 * ===================
18 */
19
20 private static $instance;
21
22
23 public static function instance() {
24
25 if(!self::$instance) {
26 self::$instance = new self();
27 }
28
29 return self::$instance;
30
31 }
32
33
34 /**
35 * =========================
36 * Execution point
37 * =========================
38 */
39
40 public function init() {
41
42 add_action('wp_login', [$this, 'after_login'], 10, 2);
43
44 add_action('profile_update', [$this, 'after_password_rest']);
45
46 add_action('init', [$this, 'rest_api']);
47
48 }
49
50
51 public function rest_api() {
52
53 add_action('rest_api_init', function() {
54 register_rest_route('wp-social', 'user/meta', [
55 'methods' => 'GET',
56 'callback' => [$this, 'check_meta'],
57 'permission_callback' => '__return_true',
58 ]);
59 });
60 }
61
62
63 public function check_meta() {
64 $user_meta = get_user_meta(5, 'xs_password_changed');
65 }
66
67
68 /**
69 * =====================
70 * After login
71 * =====================
72 */
73
74 public function after_login($user_login, $user) {
75
76
77 $user_meta = get_user_meta($user->ID, 'xs_password_changed', true);
78
79 /*
80 -------------------------------------
81 Check if user is created by WP Social
82 -------------------------------------
83 */
84
85 if($user_meta) {
86
87 /**
88 * Check if user changed the password.
89 * If it says 'no' that means user did
90 * not change the password so we should
91 * loggout them
92 */
93
94 if($user_meta == 'no') {
95
96 wp_logout();
97 }
98 }
99 }
100
101
102 /**
103 * ======================================
104 * After password reset
105 *=======================================
106 */
107
108 public function after_password_rest() {
109
110 $user_id = get_current_user_id();
111
112 /** If password does not change */
113
114 if(!isset($_POST['pass1']) || '' == $_POST['pass1']) {
115 return;
116 }
117
118 $user_meta = get_user_meta($user_id, 'xs_password_changed', true);
119
120 if($user_meta) {
121 update_user_meta($user_id, 'xs_password_changed', 'yes');
122 }
123 }
124 }
125