• Resolved goerg1980

    (@goerg1980)


    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

    (@tbenyon)

    Hey @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 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

    (@tbenyon)

    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.