Skip to content

Instantly share code, notes, and snippets.

@garvs
Created September 18, 2018 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garvs/b1f30d71510075c936ee9199f9831a32 to your computer and use it in GitHub Desktop.
Save garvs/b1f30d71510075c936ee9199f9831a32 to your computer and use it in GitHub Desktop.
User Role Editor Pro ure_widgets_edit_access_user filter example
<?php
add_filter('ure_widgets_edit_access_user', 'ure_restrict_widgets_edit_access_for_user', 10, 2);
/*
* $blocked - array of widgets and sidebars which should be unavailable for editing to the current user.
* $blocked['widgets'] - array with list of widgets
* $blocked['sidebars'] - array with list of sidebars
* $user - WP_User object with data about the current user
*
*/
function ure_restrict_widgets_edit_access_for_user($blocked, $user) {
if ($user->ID!==200) { // User ID for which you wish to block widgets
return $blocked;
}
$blocked['widgets'][] = 'WP_Widget_Pages';
$blocked['widgets'][] = 'WP_Widget_Calendar';
return $blocked;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment