Skip to content

Instantly share code, notes, and snippets.


Vladimir Garagulia garvs

View GitHub Profile
garvs / functions.php
Created Nov 28, 2019
Add JavaScript code to front-end page for a role
View functions.php
// Additional options for URE
// Hide parts of front-end page for selected role
add_filter( 'ure_role_additional_options', 'ure_add_front_end_js_option', 10, 1 );
function ure_add_front_end_js_option( $items ) {
$item = URE_Role_Additional_Options::create_item( 'change_front_end_css', esc_html__('Change Front-end CSS', 'user-role-editor'), 'init', 'ure_add_front_end_js_init' );
$items[$item->id] = $item;
garvs / restrict-woocommerce-reports-tabs.php
Created Nov 3, 2019
Restrict Woocommerce reports tab
View restrict-woocommerce-reports-tabs.php
add_filter( 'woocommerce_admin_reports', 'restricts_wc_reports_tabs', 10, 1 );
function restricts_wc_reports_tabs( $reports ) {
if ( current_user_can( 'manage_woocommerce' ) ) {
// do not restrict WooCommerce admin
return $reports;
garvs / ure-hide-screen-options.php
Created Apr 10, 2019
This code adds additional option to the Users->User Role Editor, which allows to hide "Screen Options" link from the top of WordPress admin pages for the selected role
View ure-hide-screen-options.php
// Add additional option "Hide Screen Options" for every role at Users->User Role Editor
add_filter('ure_role_additional_options', 'add_hide_screen_options', 10, 1);
function add_hide_screen_options( $items ) {
$item = URE_Role_Additional_Options::create_item(
esc_html__('Hide Screen Options', 'user-role-editor'),
garvs / export-roles-csv.php
Created Feb 1, 2019
Export all WordPress user roles to CSV file
View export-roles-csv.php
/* Project: User Role Editor WordPress plugin
* Adds admin menu item "Tools->Export roles (CSV)" and allows to export all user roles to CSV file with one click
* Setup: Install as a Must Use plugin:
* Author: Vladimir Garagulia
* Email:
* Site:
* License: GPL v.3
garvs / ure-widgets-edit-access-user.php
Created Sep 18, 2018
User Role Editor Pro ure_widgets_edit_access_user filter example
View ure-widgets-edit-access-user.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
garvs / restrict-wc-orders-statuses.php
Last active Jul 27, 2018
User Role Editor: Show for the role WooCommerce orders with selected status only
View restrict-wc-orders-statuses.php
add_filter('ure_role_additional_options', 'add_show_processing_orders_only_to_admin_option', 10, 1);
function add_show_processing_orders_only_to_admin_option($items) {
$item = URE_Role_Additional_Options::create_item('show_processing_orders_only', esc_html__('Show orders with =Processing= status only', 'user-role-editor'), 'init', 'show_processing_orders_only');
$items[$item->id] = $item;
return $items;
garvs / ure-supress-admin-protect.php
Created Jul 12, 2018
User Role Editor WordPress plugin - suppress admin protection
View ure-supress-admin-protect.php
add_filter('ure_supress_administrators_protection', 'switch_off_ure_administrators_protection', 10, 1);
function switch_off_ure_administrators_protection($supress_protection) {
$supress_protection = true;
return $supress_protection;
garvs / ure_addons_to_copy_for_new_blog.php
Created May 5, 2018
ure_addons_to_copy_for_new_blog filter filter
View ure_addons_to_copy_for_new_blog.php
add_filter('ure_addons_to_copy_for_new_blog', 'ure_addons_to_copy_for_new_blog', 10, 1);
function ure_addons_to_copy_for_new_blog($addons) {
$addons['admin_menu']->copy = true;
$addons['widgets_admin']->copy = true;
$addons['widgets_show']->copy = true;
$addons['meta_boxes']->copy = true;
garvs / hide-wp-logo-admin-bar-menu.php
Created Mar 5, 2018
Hide WP Logo from admin bar menu additional role option
View hide-wp-logo-admin-bar-menu.php
* This code adds additonal option to the Users->User Role Editor,
* which allows to hide WordPress Logo menu from admin bar menu for the selected role
add_filter('ure_role_additional_options', 'ure_hide_wp_logo_role_option', 10, 1);
function ure_hide_wp_logo_role_option($items) {
$item = URE_Role_Additional_Options::create_item('hide_wp_logo', esc_html__('Hide WP Logo from admin menu bar', 'user-role-editor'), 'admin_bar_menu', 'hide_wp_logo_admin_bar_menu');
$items[$item->id] = $item;
garvs / block-woocommerce-refunds-for-role.php
Last active Aug 14, 2017
Block WooCommerce refunds for role
View block-woocommerce-refunds-for-role.php
add_action('admin_head', 'hide_wc_refund_button');
function hide_wc_refund_button() {
global $post;
if (!current_user_can('sales')) {