Implement a User Switching connector #744
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
switch_to_user
action)switch_back_user
action)switch_off
action)I've had to make two small changes Stream's
Connector
andConnectors
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 thewp_stream_after_connectors_registration
action so a connector can use it to unhook actions attached to any of its connectors. This is necessary because theconnectors
property on the global$wp_stream
object hasn't been populated at this point.