Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a User Switching connector #744

merged 4 commits into from Aug 31, 2015


None yet
2 participants
Copy link

commented Aug 28, 2015

This adds a new connector which integrates with the User Switching plugin.

Stream works fine with User Switching (see #501), but it's a little sub-optimal. When you switch user, two entries get logged, one for the logout action and one for the login action.

This connector uses the actions that the User Switching plugin fires to more accurately log the actions performed (eg. Switched user to editor (Editor)), and also unhooks the default Users connector actions so the logout and login actions aren't logged. The connector also logs its actions under the Users context rather than its own.

New actions that are introduced:

I've had to make two small changes Stream's Connector and Connectors classes in addition to adding the new connector. Currently, it's impossible to unhook a connector's actions due to the anonymous instance of each connector which gets instantiated inside itself. There's no need for this, so I've switched to using $this.

In addition, I've added $this as a parameter to the wp_stream_after_connectors_registration action so a connector can use it to unhook actions attached to any of its connectors. This is necessary because the connectors property on the global $wp_stream object hasn't been populated at this point.

johnbillion added some commits Aug 28, 2015

Don't re-instantiate every connector class when adding actions. This …
…allows connector actions to be unhooked, which it's currently impossible to do.

This comment has been minimized.

Copy link

commented Aug 31, 2015

This is great, @johnbillion. Thanks so much!

lukecarbis pushed a commit that referenced this pull request Aug 31, 2015

Luke Carbis
Merge pull request #744 from johnbillion/user-switching
Implement a User Switching connector

@lukecarbis lukecarbis merged commit dcb2482 into xwp:develop Aug 31, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@johnbillion johnbillion deleted the johnbillion:user-switching branch Aug 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.