Created
November 7, 2015 19:02
-
-
Save SeanChDavis/a5ac57b8aafde1274864 to your computer and use it in GitHub Desktop.
EDD restrict sales summary dashboard widget by (admin) user ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // DO NOT COPY THIS LINE | |
// remove sales summary widget | |
remove_action( 'wp_dashboard_setup', 'edd_register_dashboard_widgets', 10 ); | |
// add sales summary widget with new conditions | |
function sd_edd_register_dashboard_widgets() { | |
$no_access = array( 3, 20 ); // comma separated list of user IDs to restrict | |
$user_id = get_current_user_id(); | |
// allow view of sales summary if admin and is not on the restricted list | |
if ( current_user_can( 'view_shop_reports' ) && !in_array( $user_id, $no_access ) ) { | |
wp_add_dashboard_widget( 'edd_dashboard_sales', __('Easy Digital Downloads Sales Summary','easy-digital-downloads' ), 'edd_dashboard_sales_widget' ); | |
} else { | |
return; | |
} | |
} | |
add_action( 'wp_dashboard_setup', 'sd_edd_register_dashboard_widgets', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment