User switching – Are you sure you want to do this error.
-
Hi John, amazing plugin.
I’m running into an issue with the user switching. I can switch from the admin but when i generate the url and use that it is erroring out and saying are you sure you want to do this.
I believe this is because wp nonce isn’t validating, but I’m not sure why.Here is the code I’m using to display the results.
if ($linkin){ echo('<h2>Active Linked Accounts</h2><br/>'); foreach ($linkin as $link_user_id) { if (in_array($link_user_id, $linksent)) { $link_user = get_user_by( 'id', $link_user_id ); $link_user_name = $link_user->first_name; $link_last_name = $link_user->last_name; //switch to url generation $url = wp_nonce_url( add_query_arg( array( 'action' => 'switch_to_user', 'user_id' => $link_user_id, ), wp_login_url() ), "switch_to_user_{$user->ID}" ); echo('<a href="'.$url.'"><h3>' .$link_user_name. ' ' .$link_last_name. '</h3>Switch to this User</a><br/>'); } } } else { echo('<h2>Active Linked Accounts</h2><br/>None currently.'); }
And a sample url it’s spitting out is
https://snobahn.com/wp-login.php?action=switch_to_user&user_id=118886&_wpnonce=4fab6652aaAny thoughts as to how I can get these to switch up?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘User switching – Are you sure you want to do this error.’ is closed to new replies.