How to impersonate in Plugins

Hello,

The other day a colleague question me how he could impersonate via plugin, so the records were updated with a person that had permissions, instead of the person that didn’t have.

There is two way you can do it, first and simpler is when you go to the registration plugin tool when you are editing the step you can put a specific person impersonating that plugin. The catch is that it always be that person.

Like this:
registrationplugin_impersonate

Or you can do it via code, and you can do filters to see when it should impersonate or not. Just need to set the user id.

Like this:

code_impersonate

Hope this helps.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s