Temporary Login Without Password - Version 1.5.11

Version Description

Download this release

Release Info

Developer storeapps
Plugin Icon 128x128 Temporary Login Without Password
Version 1.5.11
Comparing to
See all releases

Code changes from version 1.5.12 to 1.5.11

admin/class-wp-temporary-login-without-password-admin.php CHANGED
@@ -527,9 +527,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
527
 
528
  $reviewurl = 'https://wordpress.org/support/plugin/temporary-login-without-password/reviews/';
529
 
530
- $current_page_url = "//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
531
-
532
- $nobugurl = add_query_arg( 'tlwp_nobug', 1, $current_page_url);
533
 
534
  echo '<div class="notice notice-warning">';
535
 
527
 
528
  $reviewurl = 'https://wordpress.org/support/plugin/temporary-login-without-password/reviews/';
529
 
530
+ $nobugurl = add_query_arg( 'tlwp_nobug', 1, menu_page_url( 'wp-temporary-login-without-password', false ) );
 
 
531
 
532
  echo '<div class="notice notice-warning">';
533
 
public/class-wp-temporary-login-without-password-public.php CHANGED
@@ -61,7 +61,7 @@ class Wp_Temporary_Login_Without_Password_Public {
61
  /**
62
  * Initialize tlwp
63
  *
64
- * Hooked to init actione3 to initilize tlwp
65
  *
66
  * @since 1.0.0
67
  *
@@ -69,56 +69,38 @@ class Wp_Temporary_Login_Without_Password_Public {
69
  */
70
  public function init_wtlwp() {
71
 
72
- if(! empty($_GET['wtlwp_token'] )) {
73
 
74
  $wtlwp_token = sanitize_key( $_GET['wtlwp_token'] ); // Input var okay.
75
  $users = Wp_Temporary_Login_Without_Password_Common::get_valid_user_based_on_wtlwp_token( $wtlwp_token );
76
 
77
- $temporary_user = '';
78
- if( !empty($users)) {
79
- $temporary_user = $users[0];
80
- }
81
-
82
- if(!empty($temporary_user)) {
83
 
84
- $temporary_user_id = $temporary_user->ID;
85
- $do_login = true;
86
- if(is_user_logged_in()) {
87
- $current_user_id = get_current_user_id();
88
- if($temporary_user_id !== $current_user_id) {
89
- wp_logout();
90
- } else {
91
- $do_login = false;
92
- }
93
- }
94
 
95
- if($do_login) {
96
- $temporary_user_login = $temporary_user->login;
97
- update_user_meta( $temporary_user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() ); // phpcs:ignore
98
- wp_set_current_user( $temporary_user_id, $temporary_user_login );
99
- wp_set_auth_cookie( $temporary_user_id );
100
 
101
- do_action( 'wp_login', $temporary_user_login, $temporary_user );
102
- }
103
 
104
- $redirect_to_url = (isset( $_REQUEST['redirect_to'])) ? $_REQUEST['redirect_to'] : apply_filters( 'login_redirect', admin_url(), false, $temporary_user ); // phpcs:ignore
105
 
106
  // If empty redirect user to admin page.
107
  if ( ! empty( $redirect_to_url ) ) {
108
  $redirect_to = $redirect_to_url;
109
  }
110
 
111
- } else {
112
- // Temporary user not found?? Redirect to home page.
113
- $redirect_to = home_url();
114
  }
115
-
116
- wp_safe_redirect( $redirect_to ); // Redirect to given url after successfull login.
117
  exit();
118
-
119
  }
120
 
121
- // Restrict unauthorized page access for temporary users
122
  if ( is_user_logged_in() ) {
123
 
124
  $user_id = get_current_user_id();
@@ -126,6 +108,8 @@ class Wp_Temporary_Login_Without_Password_Public {
126
  if ( Wp_Temporary_Login_Without_Password_Common::is_login_expired( $user_id ) ) {
127
  wp_logout();
128
  wp_safe_redirect( home_url() );
 
 
129
  exit();
130
  } else {
131
 
@@ -140,7 +124,6 @@ class Wp_Temporary_Login_Without_Password_Public {
140
  }
141
  }
142
  }
143
-
144
  }
145
 
146
  /**
61
  /**
62
  * Initialize tlwp
63
  *
64
+ * Hooked to init filter to initilize tlwp
65
  *
66
  * @since 1.0.0
67
  *
69
  */
70
  public function init_wtlwp() {
71
 
72
+ if ( ! is_user_logged_in() && ! empty( $_GET['wtlwp_token'] ) ) { // phpcs:ignore
73
 
74
  $wtlwp_token = sanitize_key( $_GET['wtlwp_token'] ); // Input var okay.
75
  $users = Wp_Temporary_Login_Without_Password_Common::get_valid_user_based_on_wtlwp_token( $wtlwp_token );
76
 
 
 
 
 
 
 
77
 
78
+ if ( empty( $users ) ) {
79
+ wp_safe_redirect( home_url() );
80
+ } else {
81
+ $user = $users[0];
 
 
 
 
 
 
82
 
83
+ $user_id = $user->ID;
84
+ $user_login = $user->login;
85
+ update_user_meta( $user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() ); // phpcs:ignore
86
+ wp_set_current_user( $user_id, $user_login );
87
+ wp_set_auth_cookie( $user_id );
88
 
89
+ $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : admin_url();
90
+ $redirect_to_url = apply_filters( 'login_redirect', $redirect_to, false, $user ); // phpcs:ignore
91
 
92
+ do_action( 'wp_login', $user_login, $user );
93
 
94
  // If empty redirect user to admin page.
95
  if ( ! empty( $redirect_to_url ) ) {
96
  $redirect_to = $redirect_to_url;
97
  }
98
 
99
+ wp_safe_redirect( $redirect_to ); // Redirect to given url after successfull login.
 
 
100
  }
 
 
101
  exit();
 
102
  }
103
 
 
104
  if ( is_user_logged_in() ) {
105
 
106
  $user_id = get_current_user_id();
108
  if ( Wp_Temporary_Login_Without_Password_Common::is_login_expired( $user_id ) ) {
109
  wp_logout();
110
  wp_safe_redirect( home_url() );
111
+
112
+
113
  exit();
114
  } else {
115
 
124
  }
125
  }
126
  }
 
127
  }
128
 
129
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: temporary access, developer access, admin login, temporary login, passwordless login, customer login, secure login, access, admin, log in, login, login security, protection, user login, user login, wordpress admin login, wordpress login, wp-admin, wp-login, expiration, login, Login Without Password, user, WordPress Admin, wp-admin, developer login
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.8
7
- Stable tag: 1.5.12
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -68,13 +68,9 @@ No. at this moment it's not possible to do this.
68
 
69
  == Changelog ==
70
 
71
- **1.5.12 [2018-10-24]**
72
-
73
- * Fix: Temporary user redirected to admin page even if 'redirect_to' query param present once user logged in with temporary login link.
74
-
75
  **1.5.11 [2018-10-08]**
76
 
77
- * Update: Added filter for expiry_option. Now, one can add any custom expiry_option for the temporary login. [See example](https://wordpress.org/support/topic/additional-expiry-option/)
78
 
79
  **1.5.10 [2018-09-12]**
80
 
4
  Tags: temporary access, developer access, admin login, temporary login, passwordless login, customer login, secure login, access, admin, log in, login, login security, protection, user login, user login, wordpress admin login, wordpress login, wp-admin, wp-login, expiration, login, Login Without Password, user, WordPress Admin, wp-admin, developer login
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.8
7
+ Stable tag: 1.5.11
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
68
 
69
  == Changelog ==
70
 
 
 
 
 
71
  **1.5.11 [2018-10-08]**
72
 
73
+ * Update: Added filter for expiry_option. Now, one can add any custom expiry_option for the temporary login.
74
 
75
  **1.5.10 [2018-09-12]**
76
 
temporary-login-without-password.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Temporary Login Without Password
4
  * Plugin URI: http://www.storeapps.org/create-secure-login-without-password-for-wordpress/
5
  * 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.
6
- * Version: 1.5.12
7
  * Author: StoreApps
8
  * Author URI: https://storeapps.org
9
  * Requires at least: 3.0.1
@@ -26,7 +26,7 @@ if ( ! defined( 'WPINC' ) ) {
26
  * Define constants
27
  */
28
  define( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
29
- define( 'WTLWP_PLUGIN_VERSION', '1.5.12' );
30
  define( 'WTLWP_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
31
 
32
  /**
3
  * Plugin Name: Temporary Login Without Password
4
  * Plugin URI: http://www.storeapps.org/create-secure-login-without-password-for-wordpress/
5
  * 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.
6
+ * Version: 1.5.11
7
  * Author: StoreApps
8
  * Author URI: https://storeapps.org
9
  * Requires at least: 3.0.1
26
  * Define constants
27
  */
28
  define( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
29
+ define( 'WTLWP_PLUGIN_VERSION', '1.5.11' );
30
  define( 'WTLWP_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
31
 
32
  /**