Title: Adding custom code to WordPress
Last modified: August 22, 2016

---

# Adding custom code to WordPress

 *  [fedomain](https://wordpress.org/support/users/fedomain/)
 * (@fedomain)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-code-to-wordpress/)
 * Hi,
 * I am new to customising WordPress.
    I want to create a guest user account that
   basically have all the access except for seeing the Users menu.
 * I’ve found this page on the function that will do the job but have not sure where
   to put the code to run it.
 * [https://codex.wordpress.org/Function_Reference/remove_cap](https://codex.wordpress.org/Function_Reference/remove_cap)
 * Can anyone please tell me where to write this code and how to run it?
 * I’ve read that maybe creating a page template?
    But I think I only need to do
   this once and that specific user will have no access to the Users menu.
 * Or should remove that capability from the db?
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-code-to-wordpress/#post-5952007)
 * You can put the code to the active theme’s functions.php file.
 *  Thread Starter [fedomain](https://wordpress.org/support/users/fedomain/)
 * (@fedomain)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-code-to-wordpress/#post-5952028)
 * Thanks, Rajesh.
    I’ve added the following code to my functions.php in my child
   theme folder but it is not doing anything.
 *     ```
       function remove_edit_users_from_specific_user() {
       // Remove a capability from a specific user.
       $user_id = 2; // The ID of the user to remove the capability from.
       $user = new WP_User( $user_id );
       $user->remove_cap( 'edit_users' );
       }
       ```
   
 * Do I need to refresh or reload something?
 * Thanks.
 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-code-to-wordpress/#post-5952105)
 * You also need to call that function.
 * Add this…
 *     ```
       remove_edit_users_from_specific_user()
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding custom code to WordPress’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-code-to-wordpress/#post-5952105)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
