Title: Retrieve extra user fields from external database
Last modified: July 13, 2020

---

# Retrieve extra user fields from external database

 *  Resolved [goerg1980](https://wordpress.org/support/users/goerg1980/)
 * (@goerg1980)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/retrieve-extra-user-fields-from-external-database/)
 * Hi Tom
    The external plugin is awesome and is working fine but I need to retrieve
   extra fields from the external database to save in wp_meta. I need to know where(
   supposedly in db.php) you read and create an array to fill the wp_user data so
   I can add the required fields to fetch.
 * Thank you in advance

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

 *  Plugin Author [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * (@tbenyon)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/retrieve-extra-user-fields-from-external-database/#post-13141118)
 * Hey [@goerg1980](https://wordpress.org/support/users/goerg1980/),
 * Apologies for the delayed response. I actually wrote you a response midweek but
   having come back to check in I see that I never sent it?! Will write again now...
 * If the fields that you require are in the same table on the external database,
   there is a hook that I’ve added which will help achieve what you are looking 
   for.
 * There’s some information in the [FAQ](https://wordpress.org/plugins/external-login/#what%20hooks%20are%20available%20in%20the%20external%20login%20flow%3F)
   on the available hooks but I’ll write you some basic pseudo code to get you going
   🙂
 *     ```
       function my_function_to_do_something_after_authentication($wp_user, $exlog_user_data) {
   
         $updated = update_user_meta( $wp_user->ID, 'client_pet_name', $exlog_user_data['pets_name'] );
   
         // Checking if added ok
         if ($updated) {
           error_log('Additional field added');
         } else {
           error_log('Unable to add additional field');
         }
       }
   
       add_action('exlog_hook_action_authenticated', 'my_function_to_do_something_after_authentication', 10, 2);
       ```
   
 * Not tested but in theory this would get information stored in your external database
   under the field ‘pets_name’ and would store it in the WordPress meta value ‘client_pet_name’.
 * Let me know if you have any questions and apologies again for the delay 🙂
 * Thanks,
 * Tom
 *  Plugin Author [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * (@tbenyon)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/retrieve-extra-user-fields-from-external-database/#post-13332241)
 * I haven’t heard back so I’m assuming this is resolved.
 * If you have any further questions please don’t hesitate to get back in contact.
 * Kind regards,
 * Tom 🙂

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

The topic ‘Retrieve extra user fields from external database’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/external-login_fbebd6.svg)
 * [External Login](https://wordpress.org/plugins/external-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/external-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/external-login/)
 * [Active Topics](https://wordpress.org/support/plugin/external-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/external-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/external-login/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/retrieve-extra-user-fields-from-external-database/#post-13332241)
 * Status: resolved