• Resolved stezter

    (@stezter)


    Morning Tom

    I’ve sent you some beer money. Let me know if you’re a heavy drinker and I’ll go back to the bar.

    I have another support ticket sitting with you “Bypass ExternalDB for WordPress Admin” and whilst there is a small unresolved issue there, I’m pretty sure it’s a simple one for you.

    What I ultimately need to do (you’re plugin is doing most of it already) is pull additional fields from my external database. There are a few threads discussing the same and workaround code is offered but not being a dab hand, I’m not experienced enough to follow it.

    If I am to use the ‘exlog_hook_action_authenticated’ hook to capture and transfer additional external db user fields, can you give me the code I require and tell me where to put it?

    I have external database fields (UserID & CompanyID) that I need to pull through to a user’s wp profile. I don’t know if there’s any difference between user metadata and custom fields but I need to get these fields across somehow. At is stands at the moment I have used the Profile Builder plugin to create additional custom fields (sunrise_userid & sunrise_companyid) to hold the additional data.

    Can you help me?

    many Thanks
    Steve

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author tbenyon

    (@tbenyon)

    Hey @stezter,

    The beers are much appreciated! ??

    Looks like I’ll have a sore head over the weekend ??

    Sure, let’s see if we can help you with this. I’m working today but will definitely be back to you over the weekend.

    To get us started, can you tell me if the fields that you need to carry across are in the same users table as your other data? If they are in other tables it gets a little more complicated.

    Can you let me know the names of the fields that you need to pull across also?

    Thanks again for the beer. It’s genuinely appreciated,

    Tom ??

    Thread Starter stezter

    (@stezter)

    Hi Tom

    Yes, the fields I need to pull across are all in the same table.

    I need to pull across external fields (UserID, CompanyID) and map them to WP fields (sunrise_userid, sunrise_companyid) respectively. I probably need a few more but if I saw the code for these then I could add additional ones myself.

    Thanks Tom
    Regards
    Steve

    Plugin Author tbenyon

    (@tbenyon)

    Hey @stezter,

    Just keeping you updated.

    I’ve found that I need to make a new release for you to achieve what you want but I’ve got the bit you need working locally.

    It won’t work yet, but after the release you’ll need to add the following code to your functions.php file:

    
    function stezter_exlog_add_additional_user_data($wp_user, $exlog_user_data, $rawResponse) {
        update_user_meta(
            $wp_user->ID,               // User ID
            'sunrise_userid',           // WP Meta field key
            $rawResponse['UserID'],     // External table data
            false                       // Not unique
        );
        update_user_meta(
            $wp_user->ID,               // User ID
            'sunrise_companyid',        // WP Meta field key
            $rawResponse['CompanyID'],  // External table data
            false                       // Not unique
        );
    }
    
    add_action('exlog_hook_action_authenticated', 'stezter_exlog_add_additional_user_data', 10, 3);
    

    Keeping this ticket open still as I haven’t done the release and I need to look into your other issue and another users query also before then.

    Thanks,

    Tom

    Thread Starter stezter

    (@stezter)

    Tom

    That’s straight forward.

    I wasn’t doubtful that you’d provide a resolution. Let me know when you’re done and I’ll send you some more beers.

    Cheers
    Steve

    Plugin Author tbenyon

    (@tbenyon)

    Thanks Steve,

    This is all ready to be deployed but I’m just seeing if any other changes are needed from your other thread so I don’t make multiple releases ??

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hey Steve,

    Just letting you know that this was released in version 1.10.0 just now.

    If you have any further questions, please don’t hesitate to get back in contact but for now I’ll mark this ticket as resolved.

    Thanks again for the beers.

    Tom ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mapping Additional Fields’ is closed to new replies.