Version Description
- Bug Fixed: Temporary user is able to ligin with email address. Now onwards, temporary user is not able to login using username/email and password
- Bug Fixed: Temporary user was able to reset password. Now onwards, thye won't be able to reset password.
- Now, role of temporary user is downgrade to "none" on deactivation of plugin and change to default on re activation of plugin
Download this release
Release Info
Developer | storeapps |
Plugin | Temporary Login Without Password |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.3
- admin/class-wp-temporary-login-without-password-admin.php +24 -19
- includes/class-wp-temporary-login-without-password-activator.php +21 -0
- includes/class-wp-temporary-login-without-password-common.php +31 -15
- includes/class-wp-temporary-login-without-password-deactivator.php +23 -0
- includes/class-wp-temporary-login-without-password-layout.php +1 -0
- includes/class-wp-temporary-login-without-password.php +10 -11
- public/class-wp-temporary-login-without-password-public.php +33 -15
- readme.txt +12 -2
- temporary-login-without-password.php +15 -1
- uninstall.php +1 -21
admin/class-wp-temporary-login-without-password-admin.php
CHANGED
@@ -43,25 +43,25 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
43 |
$data = $_POST['wtlwp_data'];
|
44 |
$email = $data['user_email'];
|
45 |
$error = false;
|
46 |
-
|
47 |
$redirect_link = '';
|
48 |
if (false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) {
|
49 |
$result = array('status' => 'error', 'message' => 'unathorised_access');
|
50 |
$error = true;
|
51 |
-
}else if (!wp_verify_nonce($_POST['wtlwp-nonce'], 'wtlwp_generate_login_url')) {
|
52 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
53 |
$error = true;
|
54 |
-
}else if (empty($data['user_email'])) {
|
55 |
$result = array('status' => 'error', 'message' => 'empty_email');
|
56 |
$error = true;
|
57 |
-
}else if (!is_email($email)) {
|
58 |
$result = array('status' => 'error', 'message' => 'not_valid_email');
|
59 |
$error = true;
|
60 |
-
}else if (!empty($data['user_email']) && email_exists($data['user_email'])) {
|
61 |
$result = array('status' => 'error', 'message' => 'email_is_in_use');
|
62 |
$error = true;
|
63 |
}
|
64 |
-
|
65 |
if (!$error) {
|
66 |
$user = Wp_Temporary_Login_Without_Password_Common::create_new_user($data);
|
67 |
if (!empty($user['error'])) {
|
@@ -74,11 +74,11 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
74 |
}
|
75 |
}
|
76 |
|
77 |
-
if(empty($redirect_link)) {
|
78 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link($result);
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
wp_redirect($redirect_link, 302);
|
83 |
exit();
|
84 |
}
|
@@ -96,7 +96,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
96 |
if (!wp_verify_nonce($nonce, 'manage-temporary-login_' . $user_id)) {
|
97 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
98 |
$error = true;
|
99 |
-
} else if(!Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, false)) {
|
100 |
$result = array('status' => 'error', 'message' => 'is_not_temporary_login');
|
101 |
$error = true;
|
102 |
}
|
@@ -120,12 +120,12 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
120 |
if ((false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) || empty($_REQUEST['wtlwp_action']) || ($_REQUEST['wtlwp_action'] != 'disable' && $_REQUEST['wtlwp_action'] != 'enable') || empty($_REQUEST['user_id']) || (absint($_REQUEST['user_id']) == 0)) {
|
121 |
return;
|
122 |
}
|
123 |
-
|
124 |
$error = false;
|
125 |
$user_id = absint($_REQUEST['user_id']);
|
126 |
$action = $_REQUEST['wtlwp_action'];
|
127 |
$nonce = $_REQUEST['manage-temporary-login'];
|
128 |
-
|
129 |
$is_valid_temporary_user = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, false);
|
130 |
|
131 |
if (!$is_valid_temporary_user) {
|
@@ -135,8 +135,8 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
135 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
136 |
$error = true;
|
137 |
}
|
138 |
-
|
139 |
-
if(!$error) {
|
140 |
if ($action == 'disable') {
|
141 |
$disable_login = Wp_Temporary_Login_Without_Password_Common::manage_login(absint($user_id), 'disable');
|
142 |
if ($disable_login) {
|
@@ -147,7 +147,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
147 |
}
|
148 |
} else if ($action == 'enable') {
|
149 |
$enable_login = Wp_Temporary_Login_Without_Password_Common::manage_login(absint($user_id), 'enable');
|
150 |
-
|
151 |
if ($enable_login) {
|
152 |
$result = array('status' => 'success', 'message' => 'login_enabled');
|
153 |
} else {
|
@@ -159,7 +159,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
159 |
$error = true;
|
160 |
}
|
161 |
}
|
162 |
-
|
163 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link($result);
|
164 |
wp_redirect($redirect_link, 302);
|
165 |
exit();
|
@@ -192,7 +192,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
192 |
case 'empty_email':
|
193 |
$message = __('Please enter valid email address. Email field should not be empty', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
194 |
break;
|
195 |
-
|
196 |
case 'not_valid_email':
|
197 |
$message = __('Please enter valid email address', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
198 |
break;
|
@@ -233,7 +233,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
233 |
case 'login_enabled':
|
234 |
$message = __('Login enabled successfully!', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
235 |
break;
|
236 |
-
|
237 |
default:
|
238 |
$message = __('Success!', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
239 |
break;
|
@@ -257,10 +257,15 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
257 |
return;
|
258 |
}
|
259 |
|
|
|
|
|
|
|
|
|
260 |
public function disable_welcome_notification($blog_id, $user_id, $password, $title, $meta) {
|
261 |
|
262 |
if (!empty($user_id)) {
|
263 |
-
|
|
|
264 |
return false;
|
265 |
}
|
266 |
}
|
43 |
$data = $_POST['wtlwp_data'];
|
44 |
$email = $data['user_email'];
|
45 |
$error = false;
|
46 |
+
|
47 |
$redirect_link = '';
|
48 |
if (false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) {
|
49 |
$result = array('status' => 'error', 'message' => 'unathorised_access');
|
50 |
$error = true;
|
51 |
+
} else if (!wp_verify_nonce($_POST['wtlwp-nonce'], 'wtlwp_generate_login_url')) {
|
52 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
53 |
$error = true;
|
54 |
+
} else if (empty($data['user_email'])) {
|
55 |
$result = array('status' => 'error', 'message' => 'empty_email');
|
56 |
$error = true;
|
57 |
+
} else if (!is_email($email)) {
|
58 |
$result = array('status' => 'error', 'message' => 'not_valid_email');
|
59 |
$error = true;
|
60 |
+
} else if (!empty($data['user_email']) && email_exists($data['user_email'])) {
|
61 |
$result = array('status' => 'error', 'message' => 'email_is_in_use');
|
62 |
$error = true;
|
63 |
}
|
64 |
+
|
65 |
if (!$error) {
|
66 |
$user = Wp_Temporary_Login_Without_Password_Common::create_new_user($data);
|
67 |
if (!empty($user['error'])) {
|
74 |
}
|
75 |
}
|
76 |
|
77 |
+
if (empty($redirect_link)) {
|
78 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link($result);
|
79 |
}
|
80 |
+
|
81 |
+
|
82 |
wp_redirect($redirect_link, 302);
|
83 |
exit();
|
84 |
}
|
96 |
if (!wp_verify_nonce($nonce, 'manage-temporary-login_' . $user_id)) {
|
97 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
98 |
$error = true;
|
99 |
+
} else if (!Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, false)) {
|
100 |
$result = array('status' => 'error', 'message' => 'is_not_temporary_login');
|
101 |
$error = true;
|
102 |
}
|
120 |
if ((false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) || empty($_REQUEST['wtlwp_action']) || ($_REQUEST['wtlwp_action'] != 'disable' && $_REQUEST['wtlwp_action'] != 'enable') || empty($_REQUEST['user_id']) || (absint($_REQUEST['user_id']) == 0)) {
|
121 |
return;
|
122 |
}
|
123 |
+
|
124 |
$error = false;
|
125 |
$user_id = absint($_REQUEST['user_id']);
|
126 |
$action = $_REQUEST['wtlwp_action'];
|
127 |
$nonce = $_REQUEST['manage-temporary-login'];
|
128 |
+
|
129 |
$is_valid_temporary_user = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, false);
|
130 |
|
131 |
if (!$is_valid_temporary_user) {
|
135 |
$result = array('status' => 'error', 'message' => 'nonce_failed');
|
136 |
$error = true;
|
137 |
}
|
138 |
+
|
139 |
+
if (!$error) {
|
140 |
if ($action == 'disable') {
|
141 |
$disable_login = Wp_Temporary_Login_Without_Password_Common::manage_login(absint($user_id), 'disable');
|
142 |
if ($disable_login) {
|
147 |
}
|
148 |
} else if ($action == 'enable') {
|
149 |
$enable_login = Wp_Temporary_Login_Without_Password_Common::manage_login(absint($user_id), 'enable');
|
150 |
+
|
151 |
if ($enable_login) {
|
152 |
$result = array('status' => 'success', 'message' => 'login_enabled');
|
153 |
} else {
|
159 |
$error = true;
|
160 |
}
|
161 |
}
|
162 |
+
|
163 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link($result);
|
164 |
wp_redirect($redirect_link, 302);
|
165 |
exit();
|
192 |
case 'empty_email':
|
193 |
$message = __('Please enter valid email address. Email field should not be empty', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
194 |
break;
|
195 |
+
|
196 |
case 'not_valid_email':
|
197 |
$message = __('Please enter valid email address', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
198 |
break;
|
233 |
case 'login_enabled':
|
234 |
$message = __('Login enabled successfully!', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
235 |
break;
|
236 |
+
|
237 |
default:
|
238 |
$message = __('Success!', Wp_Temporary_Login_Without_Password_i18n::$text_domain);
|
239 |
break;
|
257 |
return;
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
+
*
|
262 |
+
* Disable welcome notification for temporary user.
|
263 |
+
*/
|
264 |
public function disable_welcome_notification($blog_id, $user_id, $password, $title, $meta) {
|
265 |
|
266 |
if (!empty($user_id)) {
|
267 |
+
$check_expiry = false;
|
268 |
+
if (Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, $check_expiry)) {
|
269 |
return false;
|
270 |
}
|
271 |
}
|
includes/class-wp-temporary-login-without-password-activator.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wp_Temporary_Login_Without_Password_Activator {
|
4 |
+
|
5 |
+
public static function activate() {
|
6 |
+
|
7 |
+
$temporary_logins_data = get_option('temporary_logins_data', array());
|
8 |
+
|
9 |
+
if (count($temporary_logins_data) > 0) {
|
10 |
+
foreach ($temporary_logins_data as $user_id => $user_role) {
|
11 |
+
wp_update_user(array('ID' => $user_id, 'role' => $user_role));
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
$add = 'yes';
|
16 |
+
|
17 |
+
// Empty set
|
18 |
+
update_option('temporary_logins_data', array(), $add);
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
includes/class-wp-temporary-login-without-password-common.php
CHANGED
@@ -62,7 +62,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
62 |
update_user_meta($user_id, '_wtlwp_created', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp());
|
63 |
update_user_meta($user_id, '_wtlwp_expire', Wp_Temporary_Login_Without_Password_Common::get_user_expire_time($time));
|
64 |
update_user_meta($user_id, '_wtlwp_token', Wp_Temporary_Login_Without_Password_Common::generate_wtlwp_token($user_id));
|
65 |
-
|
66 |
update_user_meta($user_id, 'show_welcome_panel', 0);
|
67 |
|
68 |
return $user_id;
|
@@ -146,7 +146,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
146 |
return strtotime(gmdate('Y-m-d H:i:s', time()));
|
147 |
}
|
148 |
|
149 |
-
public static function get_temporary_logins() {
|
150 |
|
151 |
$args = array(
|
152 |
'fields' => 'all',
|
@@ -267,7 +267,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
267 |
if (empty($token)) {
|
268 |
return false;
|
269 |
}
|
270 |
-
|
271 |
$args = array(
|
272 |
'fields' => $fields,
|
273 |
'meta_key' => '_wtlwp_expire',
|
@@ -304,10 +304,10 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
304 |
if (empty($user_id)) {
|
305 |
return false;
|
306 |
}
|
307 |
-
|
308 |
$check = get_user_meta($user_id, '_wtlwp_user', true);
|
309 |
-
|
310 |
-
if(!empty($check) && $check_expiry) {
|
311 |
$check = !(self::is_login_expired($user_id));
|
312 |
}
|
313 |
|
@@ -322,33 +322,33 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
322 |
|
323 |
$base_url = menu_page_url('wp-temporary-login-without-password', false);
|
324 |
$args = array();
|
325 |
-
|
326 |
-
switch($action) {
|
327 |
case 'disable';
|
328 |
-
$args = array('wtlwp_action' => 'disable','user_id' => $user_id);
|
329 |
break;
|
330 |
case 'enable';
|
331 |
-
$args = array('wtlwp_action' => 'enable','user_id' => $user_id);
|
332 |
break;
|
333 |
case 'delete';
|
334 |
-
$args = array('wtlwp_action' => 'delete','user_id' => $user_id);
|
335 |
break;
|
336 |
default:
|
337 |
break;
|
338 |
}
|
339 |
-
|
340 |
$manage_login_url = '';
|
341 |
if (!empty($args)) {
|
342 |
$base_url = add_query_arg($args, trailingslashit($base_url));
|
343 |
$manage_login_url = wp_nonce_url($base_url, 'manage-temporary-login_' . $user_id, 'manage-temporary-login');
|
344 |
-
}
|
345 |
|
346 |
return $manage_login_url;
|
347 |
}
|
348 |
|
349 |
public static function get_login_url($user_id) {
|
350 |
|
351 |
-
if (empty($user_id)
|
352 |
return;
|
353 |
}
|
354 |
|
@@ -411,7 +411,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
411 |
60 => 'minute',
|
412 |
1 => 'second'
|
413 |
);
|
414 |
-
|
415 |
$a_plural = array('year' => 'years',
|
416 |
'month' => 'months',
|
417 |
'day' => 'days',
|
@@ -438,5 +438,21 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
438 |
$blocked_pages = apply_filters('wtlwp_restricted_pages_for_temporary_users', $blocked_pages);
|
439 |
return $blocked_pages;
|
440 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
|
442 |
}
|
62 |
update_user_meta($user_id, '_wtlwp_created', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp());
|
63 |
update_user_meta($user_id, '_wtlwp_expire', Wp_Temporary_Login_Without_Password_Common::get_user_expire_time($time));
|
64 |
update_user_meta($user_id, '_wtlwp_token', Wp_Temporary_Login_Without_Password_Common::generate_wtlwp_token($user_id));
|
65 |
+
|
66 |
update_user_meta($user_id, 'show_welcome_panel', 0);
|
67 |
|
68 |
return $user_id;
|
146 |
return strtotime(gmdate('Y-m-d H:i:s', time()));
|
147 |
}
|
148 |
|
149 |
+
public static function get_temporary_logins( $role = '') {
|
150 |
|
151 |
$args = array(
|
152 |
'fields' => 'all',
|
267 |
if (empty($token)) {
|
268 |
return false;
|
269 |
}
|
270 |
+
|
271 |
$args = array(
|
272 |
'fields' => $fields,
|
273 |
'meta_key' => '_wtlwp_expire',
|
304 |
if (empty($user_id)) {
|
305 |
return false;
|
306 |
}
|
307 |
+
|
308 |
$check = get_user_meta($user_id, '_wtlwp_user', true);
|
309 |
+
|
310 |
+
if (!empty($check) && $check_expiry) {
|
311 |
$check = !(self::is_login_expired($user_id));
|
312 |
}
|
313 |
|
322 |
|
323 |
$base_url = menu_page_url('wp-temporary-login-without-password', false);
|
324 |
$args = array();
|
325 |
+
|
326 |
+
switch ($action) {
|
327 |
case 'disable';
|
328 |
+
$args = array('wtlwp_action' => 'disable', 'user_id' => $user_id);
|
329 |
break;
|
330 |
case 'enable';
|
331 |
+
$args = array('wtlwp_action' => 'enable', 'user_id' => $user_id);
|
332 |
break;
|
333 |
case 'delete';
|
334 |
+
$args = array('wtlwp_action' => 'delete', 'user_id' => $user_id);
|
335 |
break;
|
336 |
default:
|
337 |
break;
|
338 |
}
|
339 |
+
|
340 |
$manage_login_url = '';
|
341 |
if (!empty($args)) {
|
342 |
$base_url = add_query_arg($args, trailingslashit($base_url));
|
343 |
$manage_login_url = wp_nonce_url($base_url, 'manage-temporary-login_' . $user_id, 'manage-temporary-login');
|
344 |
+
}
|
345 |
|
346 |
return $manage_login_url;
|
347 |
}
|
348 |
|
349 |
public static function get_login_url($user_id) {
|
350 |
|
351 |
+
if (empty($user_id)) {
|
352 |
return;
|
353 |
}
|
354 |
|
411 |
60 => 'minute',
|
412 |
1 => 'second'
|
413 |
);
|
414 |
+
|
415 |
$a_plural = array('year' => 'years',
|
416 |
'month' => 'months',
|
417 |
'day' => 'days',
|
438 |
$blocked_pages = apply_filters('wtlwp_restricted_pages_for_temporary_users', $blocked_pages);
|
439 |
return $blocked_pages;
|
440 |
}
|
441 |
+
|
442 |
+
public static function delete_temporary_logins () {
|
443 |
+
|
444 |
+
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
445 |
+
|
446 |
+
if (count($temporary_logins) > 0) {
|
447 |
+
foreach ($temporary_logins as $user) {
|
448 |
+
if ($user instanceof WP_User) {
|
449 |
+
$user = wp_delete_user($user->ID); // Delete User
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
|
458 |
}
|
includes/class-wp-temporary-login-without-password-deactivator.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wp_Temporary_Login_Without_Password_Deactivator {
|
4 |
+
|
5 |
+
public static function deactivate() {
|
6 |
+
|
7 |
+
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
8 |
+
|
9 |
+
$temporary_logins_data = array();
|
10 |
+
if (count($temporary_logins) > 0) {
|
11 |
+
foreach ($temporary_logins as $user) {
|
12 |
+
if ($user instanceof WP_User) {
|
13 |
+
$temporary_logins_data[$user->ID] = $user->roles[0];
|
14 |
+
$user = wp_update_user(array('ID' => $user->ID, 'role' => '')); // Downgrade role to none. So, user won't be able to login
|
15 |
+
}
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
$add = 'yes';
|
20 |
+
update_option('temporary_logins_data', $temporary_logins_data, $add);
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
includes/class-wp-temporary-login-without-password-layout.php
CHANGED
@@ -51,6 +51,7 @@ class Wp_Temporary_Login_Without_Password_Layout {
|
|
51 |
|
52 |
$capabilities = $user->{$wpdb->prefix . 'capabilities'};
|
53 |
$wp_roles = new WP_Roles();
|
|
|
54 |
foreach ($wp_roles->role_names as $role => $name) {
|
55 |
if (array_key_exists($role, $capabilities)) {
|
56 |
$user_role = $name;
|
51 |
|
52 |
$capabilities = $user->{$wpdb->prefix . 'capabilities'};
|
53 |
$wp_roles = new WP_Roles();
|
54 |
+
$user_role = '';
|
55 |
foreach ($wp_roles->role_names as $role => $name) {
|
56 |
if (array_key_exists($role, $capabilities)) {
|
57 |
$user_role = $name;
|
includes/class-wp-temporary-login-without-password.php
CHANGED
@@ -1,17 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
class Wp_Temporary_Login_Without_Password {
|
4 |
-
|
5 |
protected $loader;
|
6 |
-
|
7 |
protected $plugin_name;
|
8 |
-
|
9 |
protected $version;
|
10 |
-
|
11 |
public function __construct() {
|
12 |
|
13 |
$this->plugin_name = 'wp-temporary-login-without-password';
|
14 |
-
$this->version = '1.
|
15 |
|
16 |
$this->load_dependencies();
|
17 |
$this->set_locale();
|
@@ -24,7 +22,7 @@ class Wp_Temporary_Login_Without_Password {
|
|
24 |
define($name, $value);
|
25 |
}
|
26 |
}
|
27 |
-
|
28 |
private function load_dependencies() {
|
29 |
|
30 |
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wp-temporary-login-without-password-loader.php';
|
@@ -44,7 +42,7 @@ class Wp_Temporary_Login_Without_Password {
|
|
44 |
|
45 |
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
|
46 |
}
|
47 |
-
|
48 |
private function define_admin_hooks() {
|
49 |
|
50 |
$plugin_admin = new Wp_Temporary_Login_Without_Password_Admin($this->get_plugin_name(), $this->get_version());
|
@@ -57,16 +55,17 @@ class Wp_Temporary_Login_Without_Password {
|
|
57 |
$this->loader->add_action('admin_init', $plugin_admin, 'delete_user');
|
58 |
$this->loader->add_action('admin_init', $plugin_admin, 'manage_temporary_login');
|
59 |
$this->loader->add_action('admin_notices', $plugin_admin, 'display_admin_notices');
|
60 |
-
|
61 |
$this->loader->add_filter('wpmu_welcome_notification', $plugin_admin, 'disable_welcome_notification', 10, 5);
|
62 |
}
|
63 |
|
64 |
private function define_public_hooks() {
|
65 |
|
66 |
$plugin_public = new Wp_Temporary_Login_Without_Password_Public($this->get_plugin_name(), $this->get_version());
|
67 |
-
|
68 |
$this->loader->add_action('init', $plugin_public, 'init_wtlwp');
|
69 |
-
$this->loader->add_filter('
|
|
|
70 |
}
|
71 |
|
72 |
public function run() {
|
@@ -76,7 +75,7 @@ class Wp_Temporary_Login_Without_Password {
|
|
76 |
public function get_plugin_name() {
|
77 |
return $this->plugin_name;
|
78 |
}
|
79 |
-
|
80 |
public function get_loader() {
|
81 |
return $this->loader;
|
82 |
}
|
1 |
<?php
|
2 |
|
3 |
class Wp_Temporary_Login_Without_Password {
|
4 |
+
|
5 |
protected $loader;
|
|
|
6 |
protected $plugin_name;
|
|
|
7 |
protected $version;
|
8 |
+
|
9 |
public function __construct() {
|
10 |
|
11 |
$this->plugin_name = 'wp-temporary-login-without-password';
|
12 |
+
$this->version = '1.3';
|
13 |
|
14 |
$this->load_dependencies();
|
15 |
$this->set_locale();
|
22 |
define($name, $value);
|
23 |
}
|
24 |
}
|
25 |
+
|
26 |
private function load_dependencies() {
|
27 |
|
28 |
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wp-temporary-login-without-password-loader.php';
|
42 |
|
43 |
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
|
44 |
}
|
45 |
+
|
46 |
private function define_admin_hooks() {
|
47 |
|
48 |
$plugin_admin = new Wp_Temporary_Login_Without_Password_Admin($this->get_plugin_name(), $this->get_version());
|
55 |
$this->loader->add_action('admin_init', $plugin_admin, 'delete_user');
|
56 |
$this->loader->add_action('admin_init', $plugin_admin, 'manage_temporary_login');
|
57 |
$this->loader->add_action('admin_notices', $plugin_admin, 'display_admin_notices');
|
58 |
+
|
59 |
$this->loader->add_filter('wpmu_welcome_notification', $plugin_admin, 'disable_welcome_notification', 10, 5);
|
60 |
}
|
61 |
|
62 |
private function define_public_hooks() {
|
63 |
|
64 |
$plugin_public = new Wp_Temporary_Login_Without_Password_Public($this->get_plugin_name(), $this->get_version());
|
65 |
+
|
66 |
$this->loader->add_action('init', $plugin_public, 'init_wtlwp');
|
67 |
+
$this->loader->add_filter('wp_authenticate_user', $plugin_public, 'disable_temporary_user_login', 10, 2);
|
68 |
+
$this->loader->add_filter('allow_password_reset', $plugin_public, 'disable_password_reset', 10, 2);
|
69 |
}
|
70 |
|
71 |
public function run() {
|
75 |
public function get_plugin_name() {
|
76 |
return $this->plugin_name;
|
77 |
}
|
78 |
+
|
79 |
public function get_loader() {
|
80 |
return $this->loader;
|
81 |
}
|
public/class-wp-temporary-login-without-password-public.php
CHANGED
@@ -69,26 +69,44 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
$
|
84 |
-
|
85 |
-
if ($is_login_expired) {
|
86 |
$user = new WP_Error('denied', __("ERROR: User can't find."));
|
87 |
-
remove_action('authenticate', 'wp_authenticate_username_password', 20);
|
88 |
}
|
89 |
}
|
90 |
|
91 |
return $user;
|
92 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
}
|
69 |
}
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* Hooked to wp_authenticate_user filter to disable login for temporary user using username/email and password
|
74 |
+
*
|
75 |
+
* @param type $user
|
76 |
+
* @param type $password
|
77 |
+
* @return \WP_Error
|
78 |
+
*/
|
79 |
+
function disable_temporary_user_login($user, $password) {
|
80 |
+
|
81 |
+
if ($user instanceof WP_User) {
|
82 |
+
$check_expiry = false;
|
83 |
+
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user->ID, $check_expiry);
|
84 |
+
if ($is_valid_temporary_login) {
|
|
|
85 |
$user = new WP_Error('denied', __("ERROR: User can't find."));
|
|
|
86 |
}
|
87 |
}
|
88 |
|
89 |
return $user;
|
90 |
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Hooked to allow_password_reset filter to disable reset password for temporary user
|
94 |
+
*
|
95 |
+
* @param boolean $allow
|
96 |
+
* @param type $user_id
|
97 |
+
* @return boolean
|
98 |
+
*/
|
99 |
+
function disable_password_reset($allow, $user_id) {
|
100 |
+
|
101 |
+
if (is_int($user_id)) {
|
102 |
+
$check_expiry = false;
|
103 |
+
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login($user_id, $check_expiry);
|
104 |
+
if ($is_valid_temporary_login) {
|
105 |
+
$allow = false;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return $allow;
|
110 |
+
}
|
111 |
|
112 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: storeapps, niravmehta, malayladu
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPTHCDC382KVA
|
4 |
Tags: admin, custom login, login, temporary login, wp admin, wordpress admin, access, expiration, user, login without password
|
5 |
Requires at least: 3.0.1
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -40,6 +40,16 @@ If you like Temporary Login Without Password, please leave a five star review on
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
= 1.1 =
|
44 |
|
45 |
- Bug Fixed: Temporary user redirected to login page instead of admin dashboard after successful login.
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPTHCDC382KVA
|
4 |
Tags: admin, custom login, login, temporary login, wp admin, wordpress admin, access, expiration, user, login without password
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.6
|
7 |
+
Stable tag: 1.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 1.3 =
|
44 |
+
|
45 |
+
- Bug Fixed: Temporary user is able to ligin with email address. Now onwards, temporary user is not able to login using username/email and password
|
46 |
+
- Bug Fixed: Temporary user was able to reset password. Now onwards, thye won't be able to reset password.
|
47 |
+
- Now, role of temporary user is downgrade to "none" on deactivation of plugin and change to default on re activation of plugin
|
48 |
+
|
49 |
+
= 1.2 =
|
50 |
+
|
51 |
+
- Bug Fixed: Temporary user is able to login with username and password.
|
52 |
+
|
53 |
= 1.1 =
|
54 |
|
55 |
- Bug Fixed: Temporary user redirected to login page instead of admin dashboard after successful login.
|
temporary-login-without-password.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Temporary Login Without Password
|
5 |
* Plugin URI: http://storeapps.org
|
6 |
* Description: Create a temporary login link with any role using which one can access to your sytem without username and password for limited period of time.
|
7 |
-
* Version: 1.
|
8 |
* Author: StoreApps
|
9 |
* Author URI: http://storeapps.org
|
10 |
* License: GPL-2.0+
|
@@ -17,6 +17,20 @@ if (!defined('WPINC')) {
|
|
17 |
die;
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
// Include main class file
|
21 |
require plugin_dir_path(__FILE__) . 'includes/class-wp-temporary-login-without-password.php';
|
22 |
|
4 |
* Plugin Name: Temporary Login Without Password
|
5 |
* Plugin URI: http://storeapps.org
|
6 |
* Description: Create a temporary login link with any role using which one can access to your sytem without username and password for limited period of time.
|
7 |
+
* Version: 1.3
|
8 |
* Author: StoreApps
|
9 |
* Author URI: http://storeapps.org
|
10 |
* License: GPL-2.0+
|
17 |
die;
|
18 |
}
|
19 |
|
20 |
+
function wp_deactivate_temporary_login_without_password () {
|
21 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-deactivator.php';
|
22 |
+
Wp_Temporary_Login_Without_Password_Deactivator::deactivate();
|
23 |
+
}
|
24 |
+
|
25 |
+
function wp_activate_temporary_login_without_password () {
|
26 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-activator.php';
|
27 |
+
Wp_Temporary_Login_Without_Password_Activator::activate();
|
28 |
+
}
|
29 |
+
|
30 |
+
register_deactivation_hook( __FILE__, 'wp_deactivate_temporary_login_without_password' );
|
31 |
+
register_activation_hook( __FILE__, 'wp_activate_temporary_login_without_password' );
|
32 |
+
|
33 |
+
|
34 |
// Include main class file
|
35 |
require plugin_dir_path(__FILE__) . 'includes/class-wp-temporary-login-without-password.php';
|
36 |
|
uninstall.php
CHANGED
@@ -2,30 +2,10 @@
|
|
2 |
|
3 |
/**
|
4 |
* Fired when the plugin is uninstalled.
|
5 |
-
*
|
6 |
-
* When populating this file, consider the following flow
|
7 |
-
* of control:
|
8 |
-
*
|
9 |
-
* - This method should be static
|
10 |
-
* - Check if the $_REQUEST content actually is the plugin name
|
11 |
-
* - Run an admin referrer check to make sure it goes through authentication
|
12 |
-
* - Verify the output of $_GET makes sense
|
13 |
-
* - Repeat with other user roles. Best directly by using the links/query string parameters.
|
14 |
-
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
|
15 |
-
*
|
16 |
-
* This file may be updated more in future version of the Boilerplate; however, this is the
|
17 |
-
* general skeleton and outline for how the file should work.
|
18 |
-
*
|
19 |
-
* For more information, see the following discussion:
|
20 |
-
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
21 |
-
*
|
22 |
-
* @link http://storeapps.org
|
23 |
-
* @since 1.0
|
24 |
-
*
|
25 |
-
* @package Wp_Temporary_Login_Without_Password
|
26 |
*/
|
27 |
|
28 |
// If uninstall not called from WordPress, then exit.
|
29 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
30 |
exit;
|
31 |
}
|
|
2 |
|
3 |
/**
|
4 |
* Fired when the plugin is uninstalled.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*/
|
6 |
|
7 |
// If uninstall not called from WordPress, then exit.
|
8 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
9 |
exit;
|
10 |
}
|
11 |
+
|