Home » Filter Matomo Analytics Dashboard widget capability
Filter Matomo Analytics Dashboard widget capability

SiteSEO provides a way to filter the capability of Matomo widget.

Hook: seopress_matomo_dashboard_widget_cap

Since: 1.0.0

Description: Let's user filter Matomo widget capability.

Usage:

//This code must be added to a mu-plugin in order to work
function siteseo_extended_matomo_dashboard_widget_cap(){
	//default: 'edit_dashboard' capability
	return 'edit_posts';
}
add_filter('siteseo_matomo_dashboard_widget_cap', 'siteseo_extended_matomo_dashboard_widget_cap');


//This second part is necessary to filter the capabilities checked by the AJAX Request / CRON task
add_filter('siteseo_capability', 'siteseo_extended_capability', 10, 2);
function siteseo_extended_capability($cap, $context) {
	if ($context == 'cron') {
		$cap = 'edit_posts';
	}
	return $cap;
}

Note: We suggest you use siteseo_extended_ as a prefix for every callback function, to keep things consistent and non-conflicting.

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list