User Switching
[resolved] Encoding error for switch_to_olduser nonce (3 posts)

  1. Boris
    Posted 2 years ago #

    First of all, awesome plugin! Couldn't imagine developing without it anymore.

    Just ran into a little issue locally with User Switching 0.7.1 and the latest WP 3.6 dev version. Basically, every time I wanted to switch back to the old user I'd get a nonce error (never happened with older WP versions).

    A bit of digging turned up that the ampersand connecting the _wpnonce arg to the rest of the url gets encoded by passing it through add_query_arg again when the redirect_to arg is added, so you end up with the html entity of the ampersand.

    I then modified the switch_back_url method so that the redirect arg gets passed as a parameter, like so:

    function switch_back_url( $redirect = false ) {
    	$query_args = array(
    		'action' => 'switch_to_olduser'
    	if( $redirect )
    		$query_args['redirect_to'] = urlencode( $redirect );
    	return wp_nonce_url( add_query_arg( $query_args, wp_login_url() ), 'switch_to_olduser' );

    This fixed things for me. I imagine that the switch_off_url method causes the same issue, but can't test it, cause I'm using a custom admin theme with a modified admin bar.

    Be great if you could look into the problem and maybe get a fix out. Cheers!



  2. John Blackbourn
    WordPress Core Developer
    Plugin Author

    Posted 2 years ago #

    Hey Boris,

    This was a bug that was introduced in WordPress trunk (3.6) a couple of weeks back and subsequently fixed a few days ago: http://core.trac.wordpress.org/ticket/20771#comment:8

    If you update to the latest nightly build it should work as expected.


  3. Boris
    Posted 2 years ago #

    Alright, cheers!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Switching
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic