Title: Modifying core function
Last modified: August 19, 2016

---

# Modifying core function

 *  [rwc](https://wordpress.org/support/users/rwc/)
 * (@rwc)
 * [17 years ago](https://wordpress.org/support/topic/modifying-core-function/)
 * Hi, I have a question about modifying a core function, as explained in the documentation:
 * [http://codex.wordpress.org/Plugin_API](http://codex.wordpress.org/Plugin_API)
 * If I want to essentially add some code to wp_insert_user (to add that user to
   a separate database), can I simply “extend” the current wp_insert_user so that
   it executes some additional code on top of what the core function already does?
 * From what I’ve seen, when you apply the hook/filter, it *replaces* the core function,
   meaning I have to copy all the current code out of wp_insert_user in my plugin
   and then add my custom code to it, which seems to defeat the purpose … am I wrong?
 * I want the core wp_insert_user code to work off the actual core code, then I 
   want it to call my function with the same parameter, so I can execute my block
   of code. Help anyone?
 * I want to *add to* the core function, not *replace* the core function.
 * Thanks.

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

 *  Thread Starter [rwc](https://wordpress.org/support/users/rwc/)
 * (@rwc)
 * [17 years ago](https://wordpress.org/support/topic/modifying-core-function/#post-1026907)
 * Furthermore, it doesn’t even appear that you can *replace* wp_insert_user using
   add_filter and remove_filter or add_action and remove_action, let alone add to
   it. Same goes for wp_update_user, wp_set_password, etc. … Anyone?
 *  [tapeboy929](https://wordpress.org/support/users/tapeboy929/)
 * (@tapeboy929)
 * [17 years ago](https://wordpress.org/support/topic/modifying-core-function/#post-1026909)
 * One thing you can do is write an entirely new function in wp-includes/registration-
   functions.php. Then add a function call to the existing function. For example,
   create a new function called ‘updateMyDB()’ and then open up wp-admin/admin-functions.
   php-
 * Change
 *     ```
       if ($update) {
         $user_id = wp_update_user(get_object_vars($user));
       } else {
         $user_id = wp_insert_user(get_object_vars($user));
         wp_new_user_notification($user_id);
       }
       ```
   
 * to
 *     ```
       if ($update) {
         $user_id = wp_update_user(get_object_vars($user));
       } else {
         $user_id = wp_insert_user(get_object_vars($user));
         wp_new_user_notification($user_id);
         updateMyDB($user_id);
       }
       ```
   
 * That should work out for you. Good luck.
 * [**signature moderated** Please read the [Forum Rules](http://wordpress.org/support/topic/68664?replies=6)]
 *  Thread Starter [rwc](https://wordpress.org/support/users/rwc/)
 * (@rwc)
 * [17 years ago](https://wordpress.org/support/topic/modifying-core-function/#post-1026912)
 * Solved it myself.
 * add_action (‘user_register’, ‘phpbb_insert_user’);

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

The topic ‘Modifying core function’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [rwc](https://wordpress.org/support/users/rwc/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/modifying-core-function/#post-1026912)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
