• Resolved Neil

    (@neilgilmour)


    WCLDN 2018 Contributor

    Hey Jory,

    Is is possible to generate a link to view as a user without using the VAA interface?

    My use case is that we support users of our site through some third party software (Intercom) and often have to view as our users to help them with support issues. If I can get a link it makes it one-click to go from Intercom to viewing as the user. Otherwise we go to the site and search for the user in the VAA toolbar widget.

    Is there a function I can call which makes the link and generates the nonce?

    Cheers,
    Neil

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi Neil,

    It’s possible to generate a link like, see: VAA_API::get_vaa_action_link()

    Keep in mind though that the user needs to be logged in before that. Also, since the link needs to have a nonce it will be different each time you log in again since nonces are based on the current user session.

    In this case I think it’s better to create some form of API for a use-case like this.
    The next update will feature some extra API methods to make it easier to do this.

    Example use case:
    The link would something like this: LINK/?switch-user=3 where 3 is the user ID.
    Code (simplified):

    
    if ( ! empty( $_GET['switch-user'] ) && method_exists( 'VAA_API', 'update_view' ) ) {
        $success = VAA_API::update_view( array( 'user' => (int) $_GET['switch-user'] ) );
        if ( $success ) {
            // Maybe do a redirect.
        }
    }
    

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    I’ve added extra API methods to v1.8.3 to use for a feature like you’ve described:

    VAA_API::update_view() & VAA_API::get_current_view()

    The code to use this API for your feature would be out of scope for this plugin itself so I’m closing this issue here!

    Regards, Jory

    Thread Starter Neil

    (@neilgilmour)

    WCLDN 2018 Contributor

    Awesome, thanks Jory! Another reason why your plugin makes our lives so much easier supporting lots of users…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can I generate a link to view as a user?’ is closed to new replies.