• Resolved Ov3rfly

    (@ov3rfly)


    Currently AntiSpam Bee does not have an option to switch on/off the dashboard widget based on a wp user role/capability.

    In a current project it was necessary to remove the widget in “non admin/editor” accounts.

    The current solution is a conditional remove_meta_box('ab_widget', 'dashboard', 'normal'); in admin_menu action.

    Unfortunately this triggers a js-error in Raphael js library when it tries to access/use the non existing #ab_chart element in dashboard.min.js when using e.g. an “author” account.

    Suggestion (simple): Add a check if the element exists before the drawing codeblock in dashboard.js, e.g. if (jQuery('#ab_chart').length > 0) {// Draw ..}

    Suggestion (complex): Add a configurable user capability to AntiSpam Bee options when to display the widget/include the js.

    Thanks for the great plugin!

    https://wordpress.org/plugins/antispam-bee/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Ov3rfly

    (@ov3rfly)

    For interested readers, instead of changing the Raphael js, we are now using a second conditional to remove the javascript for the AB dashboard widget in above case, wp_dequeue_script(x3) in a prio 100 wp_print_scripts action.

    Plugin Contributor Pascal Birchler

    (@swissspidy)

    Hey there

    Currently AntiSpam Bee does not have an option to switch on/off the dashboard widget based on a wp user role/capability.

    That’s definitely not something this plugin should be doing. Use plugins like WP Widget Disable for this.

    However, I just opened an issue on GitHub about this so we only load the JS when needed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Suggestion: Check if widget exists in dashboard.js or widget display config’ is closed to new replies.