Shop as customer changes user role in the back end as well?

Hi all,

I am enabling / disabling payment gateways depending on user roles, so I have an action hook were I check the current user role, and adjust the gateways accordingly.

If I switch user using your plugin, would the user role in the back end change also (thus invalidating my code), or will it stay 'administrator' / 'shop_manager'?

TY

M

Add Comment
5 Answer(s)

For all intents and purposes, when changing to a customer role, you ARE that customer. When you click the Switch Back button then you will become that Admin / Shop Manager again. It's not in a half-way state or anything like that.

Answered on June 12, 2017.
Add Comment

Hi,

thanks 😉

Answered on June 12, 2017.
Add Comment

Hi,

sorry, forgot to ask:

is there anything I can use to understand I am in a "switched user state"? like a wp_option or else?

that would help a lot

m

Answered on June 13, 2017.
Add Comment

.. and if not, are there any action hooks for the

  • enter switched state
  • exit switched state

I can override?

TY

Answered on June 13, 2017.
Add Comment

Hi all,

wanted to follow up on my last questions:

  1. is there anything I can use to understand I am in a "switched user state"? like a wp_option or else?
  2. and if not, are there any action / filter hooks provided by your plugin to do custom things when enter/exit switched state?

TY a million for any help

m

Answered on June 20, 2017.

Hi M

There are these hooks at the moment.

 

// Switching to...

do_action( 'shop_as_customer', $switch_to_user_id, $switch_from_user_id );
// Switching back...

do_action( 'switch_back_user', $switch_to_user_id, $switch_from_user_id );

 

The dev is going to write up some docs on using these too.

Thanks

on July 11, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.