Home » Filter Google Analytics Dashboard widget capability
Filter Google Analytics Dashboard widget capability

SiteSEO provides a way to filter the capability to for the Google Analytics Widget.

Hook: siteseo_ga_dashboard_widget_cap

Since: 1.0.0

Description: Let's user filter capability of widget.

Usage:

//This code must be added to a mu-plugin in order to work
function siteseo_extended_ga_dashboard_widget_cap(){
	return 'edit_posts';
}
add_filter('siteseo_ga_dashboard_widget_cap', 'siteseo_ga_dashboard_widget_cap');


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

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