Title: sc_21's Replies | WordPress.org

---

# sc_21

  [  ](https://wordpress.org/support/users/sc_21/)

 *   [Profile](https://wordpress.org/support/users/sc_21/)
 *   [Topics Started](https://wordpress.org/support/users/sc_21/topics/)
 *   [Replies Created](https://wordpress.org/support/users/sc_21/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/sc_21/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/sc_21/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/sc_21/engagements/)
 *   [Favorites](https://wordpress.org/support/users/sc_21/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Genesis Visual Hook Guide] How can I disable for a specific user role?](https://wordpress.org/support/topic/how-can-i-disable-for-a-specific-user-role/)
 *  Thread Starter [sc_21](https://wordpress.org/support/users/sc_21/)
 * (@sc_21)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/how-can-i-disable-for-a-specific-user-role/#post-5742106)
 * It was much easier than I thought.
    I solved the problem by insert this code 
   in function.php (sources at the bottom):
 *     ```
       // First: I create the function that allows me to retrieve the user role
   
       function appthemes_check_user_role( $role, $user_id = null ) {
           if ( is_numeric( $user_id ) ) {
               $user = get_userdata( $user_id );
           } else {
               $user = wp_get_current_user();
           }
           if ( empty( $user ) ) {
               return false;
           }
           return in_array( $role, (array) $user->roles );
       }
   
       // Second: I create and enable function that removes "G Hook Guide" button from the admin-bar of the users with role "my_role"
   
       add_action( 'wp_before_admin_bar_render', 'admin_bar_edit' );
       function admin_bar_edit() {
           if ( appthemes_check_user_role( 'my_role' )) {
               global $wp_admin_bar;
               $wp_admin_bar->remove_menu('ghooks');
           }
       }
       ```
   
 * In my language we say: “_Chi fa da sè fa per tre_” 😉
 * **Sources:**
    [http://docs.appthemes.com/tutorials/wordpress-check-user-role-function/](http://docs.appthemes.com/tutorials/wordpress-check-user-role-function/)
   [http://www.paulund.co.uk/how-to-remove-links-from-wordpress-admin-bar](http://www.paulund.co.uk/how-to-remove-links-from-wordpress-admin-bar)

Viewing 1 replies (of 1 total)