WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Boris
    Member
    Posted 1 year 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!

    ~Boris

    http://wordpress.org/extend/plugins/user-switching/

  2. John Blackbourn
    Member
    Plugin Author

    Posted 1 year 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.

    John

  3. Boris
    Member
    Posted 1 year ago #

    Alright, cheers!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic