Created
September 18, 2018 08:28
-
-
Save garvs/b1f30d71510075c936ee9199f9831a32 to your computer and use it in GitHub Desktop.
User Role Editor Pro ure_widgets_edit_access_user filter example
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 | |
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