Skip to content
5 changes: 3 additions & 2 deletions src/TrackingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function __construct( string $mixpanel_token, string $plugin, string $bra
* @param string $event Event name.
* @param mixed[] $properties Event properties.
* @param string $event_capability The capability required to track the event.
* @param bool $bypass_capability Whether to bypass capability check.
Comment thread
jeawhanlee marked this conversation as resolved.
Outdated
*/
public function track( string $event, array $properties, string $event_capability = '' ): void {
public function track( string $event, array $properties, string $event_capability = '', bool $bypass_capability = false ): void {
Comment thread
jeawhanlee marked this conversation as resolved.
Outdated
/**
* Filter the default capability required to track a specific event.
*
Expand All @@ -69,7 +70,7 @@ public function track( string $event, array $properties, string $event_capabilit
$event_capability = $default;
}

if ( ! current_user_can( $event_capability ) ) {
if ( ! $bypass_capability && ! current_user_can( $event_capability ) ) {
Comment thread
jeawhanlee marked this conversation as resolved.
Outdated
return;
}

Expand Down