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
merged 4 commits into from Aug 31, 2015
Merged

Implement a User Switching connector #744

merged 4 commits into from Aug 31, 2015

Conversation

johnbillion
Copy link
Contributor

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.

@lukecarbis
Copy link
Contributor

This is great, @johnbillion. Thanks so much!

lukecarbis pushed a commit that referenced this pull request Aug 31, 2015
Implement a User Switching connector
@lukecarbis lukecarbis merged commit dcb2482 into xwp:develop Aug 31, 2015
@johnbillion johnbillion deleted the user-switching branch August 31, 2015 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants