Hey @pwozniak89,
The problem is that I try to connect with a username that I have already created then deleted on WordPress database…
Maybe deletion have not removed all information about this account on WordPress database…
This was very interesting to me. What I expect to happen is the user would be overwritten by the external user. I’m going to put in a ticket for myself to see if I can replicate this. I’m wondering if it may be something like the user had the same username but different e-mail or the other way round. Or like you said, that the user was ‘soft’ deleted in some way. I will investigate ??
Is there a php function I can call on a page that allows me to access directly the external database to read other field for logged user?
The best way to achieve this is to map additional data as meta fields on the user. This is the WordPress way of storing additional data for a user.
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.
You can find more information on how to use the plugin hooks in the FAQ.
I haven’t tested this, so treat it like pseudo code, but you could do something like this:
function pwozniak89_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', 'pwozniak89_exlog_add_additional_user_data', 10, 2);
This code could live in your functions.php file or where ever you like to store this information.
Sorry for the inconvenience, but I’d like to thank you for this great plugin and your answers that make me think about my mistakes!
No problem at all, and I’m glad you’re getting good use from the plugin.
If it all works I’d be grateful if you could write a review or even buy me a beer.
Feel free to get back to me if you have any further questions.
Thanks,
Tom
??