Title: Map Additional Field
Last modified: December 19, 2019

---

# Map Additional Field

 *  Resolved [enduser670](https://wordpress.org/support/users/enduser670/)
 * (@enduser670)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/)
 * Hello,
    Thanks for the work on this great plugin. It is working really well.
 * I am in the process of looking over your code in order to hack in an additional
   field for the Database Table Mapping. I would like to map an additional field
   in the remote database to the nickname Meta Key inside wp_usermeta. The nickname
   field is an important field in WordPress. In my case we are using the Dokan Vendor
   plugin for Woocommerce and it uses the nickname Meta Key to assign the name of
   a vendor’s store in the URI. Like this: storedomain.com/cart/store/nickname/
   
   So when a user is created with your plugin after logging into a WordPress website,
   your plugin misses writing the nickname field in wp_usermeta. So, this requires
   manually editing this in the database in order for the Vendor store to work.
 * Here’s what I have found so far looking over your code:
 * There are several PHP files in your plugin that have a data array for each mapped
   key and what appears to be a file to handle the insert statements to the database.
   These are:
    1. BuiltPluginData.php 2 Exlog_built_plugin_data.php 3. options_fields.
   php 4. db.php (handles the inserts)
 * Am I okay to add an additional arrays to the first three files with my desired
   field like this:
 *     ```
       array(
                       "field_name" => "Nickname Vendor Cart Field Name",
                       "field_description" => "This is the name of the field that stores your vendors store name in the URL path. It MUST be unique.",
                       "field_slug" => "exlog_dbstructure_nickname",
                       "type" => "text",
                       "required" => true
                   )
       ```
   
 * And in the db.php file add the code below about line 68 inside the $data = array().
   Like this:
    `"dbstructure_nickname" => exlog_get_option('exlog_dbstructure_nickname'),`
 * And also in the db.php file add the code below about line 92 inside the exlog_build_wp_user_data()
   method. Like this:
 *     ```
       "nickname" => $userData[$db_data["dbstructure_nickname"]],
       ```
   
 * So, my question to you is have I found everything required. I could just pull
   the trigger and test it, but I was hoping to get some feedback before possibly
   making an error writing to the user table of a the site.
 * Thanks for any input you can offer and thank you so much for building this plugin.

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

 *  Thread Starter [enduser670](https://wordpress.org/support/users/enduser670/)
 * (@enduser670)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/#post-12256286)
 * After looking into this further today, I was in error in the first paragraph 
   of my first post here: “I would like to map an additional field in the remote
   database to the nickname Meta Key inside wp_usermeta.”
 * It turns out the fields(s) in the database that I need to write to are not in
   the wp_usermeta table. Instead they are inside the main wp_users table. And there
   are two columns in wp_users I need to map and write to when users log into the
   Worpress Login system and they are not a WordPress user, but they are a user 
   in the external database. The two columns I need to write to are:
 * 1. user_nicename
    2. display_name
 * Could you possibly steer me to the correct files to hack to do this?
 * I have a hunch this might be much easier as I noted this thread here…
    [https://wordpress.org/support/topic/custom-user-fields-5/](https://wordpress.org/support/topic/custom-user-fields-5/)…
   where you discussed options to map to wp_usermeta.
 * Thanks for your input on my topic.
 *  Plugin Author [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * (@tbenyon)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/#post-12262475)
 * Hey [@enduser670](https://wordpress.org/support/users/enduser670/),
 * I hadn’t properly read this post until now. Been trying to get a different release
   out for another but that is now resolved.
 * I still have plans to add custom fields to be pulled from the user table. However
   there is another way you can handle this for now.
 * If you look in my frequently asked questions section there is some details about
   [available hooks](https://wordpress.org/plugins/external-login/#what%20hooks%20are%20available%20in%20the%20external%20login%20flow%3F).
 * You could use the `exlog_hook_action_authenticated` hook to add additional meta
   fields when they get authenticated.
 * The hook pulls in the new wordpress user and all the fields grabbed from the 
   external table on the authenticated user.
 * I haven’t tested this, so treat it like pseudo code, but you could do something
   like this:
 *     ```
       function enduser670_exlog_add_additional_user_data($wp_user, $exlog_user_data) {
         add_user_meta(
           $wp_user->ID,                          // User ID
           'fav_colour',                          // WP Meta field key
           $exlog_user_data['favourite_colour'],  // External table data
           false                                  // Not unique
         );
       }
   
       add_action('exlog_hook_action_authenticated', 'enduser670_exlog_add_additional_user_data', 10, 2);
       ```
   
 * If any of this does not make sense, feel free to get back to me. Also happy to
   support further if you get an error you don’t understand.
 * Thanks,
 * Tom 🙂
 *  Thread Starter [enduser670](https://wordpress.org/support/users/enduser670/)
 * (@enduser670)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/#post-12272509)
 * Thank you for noticing the question. I know I threw you off initially by my first
   post which was in error.
 * I will look at this again soon this week. I am coding the registration and login
   script on our remote site this week. I need to review WordPress and the Registration
   validation rules and other things, but I have our site working rather well with
   RegExes, client and server-side validation and other checks. Thanks again for
   your input.
 *  Plugin Author [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * (@tbenyon)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/#post-12272538)
 * No problem! I’ll mark this as resolved for now but if you have any issues with
   this just reply back here and we’ll have a further look together.
 * Thanks, and good luck with the project! 😊

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

The topic ‘Map Additional Field’ 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/)

 * 4 replies
 * 2 participants
 * Last reply from: [tbenyon](https://wordpress.org/support/users/tbenyon/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/map-additional-field/#post-12272538)
 * Status: resolved