tbenyon
Forum Replies Created
-
Forum: Plugins
In reply to: [External Login] Mapping Additional FieldsHey @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
Forum: Plugins
In reply to: [External Login] Bypass ExternalDB for WordPress AdminNo problem, will have a propper look at this at the weekend.
I appreciate you keeping me posted on developments π
Forum: Plugins
In reply to: [External Login] Mapping Additional FieldsHey @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 π
Hey @chuckmo,
I really appreciate the beers π
You’ve actually inspired me to go out later for a pint so much appreciated.
Before we look at this solution, can you lie to the plugin for me . . .
In the field mappings, can you tell the plugin that the your email field is both the username and the password.
I think this will solve your problem π
If not, get back to me π
Forum: Plugins
In reply to: [External Login] Bypass ExternalDB for WordPress AdminI need to get on with my day job so can’t test now but had a quick look.
I think it might be because of migration mode. I’ll check at the weekend but on the off chance you want to test this in the mean time I thought I’d share this.
At the bottom of
login/authenticate.phpin the plugin folder there is this code:// Hook that passes user data on successful login do_action('exlog_hook_action_authenticated', $user, $exlog_userdata); } } // Whether to disable login fallback with the local WordPress version of the username and password // Prevents local login if: // - Disable local login is set in the admin area // - OR // - The user was found but the password was rejected if (exlog_get_option('external_login_option_disable_local_login') == "on" || is_wp_error($user)) { remove_action('authenticate', 'wp_authenticate_username_password', 20); } } return $user; } if (exlog_get_option("external_login_option_enable_external_login") == "on") { add_filter('authenticate', 'exlog_auth', 10, 3); }I speculate that the issue may be fixed if you change it to:
// Hook that passes user data on successful login do_action('exlog_hook_action_authenticated', $user, $exlog_userdata); } } } // Whether to disable login fallback with the local WordPress version of the username and password // Prevents local login if: // - Disable local login is set in the admin area // - OR // - The user was found but the password was rejected if (exlog_get_option('external_login_option_disable_local_login') == "on" || is_wp_error($user)) { remove_action('authenticate', 'wp_authenticate_username_password', 20); } return $user; } if (exlog_get_option("external_login_option_enable_external_login") == "on") { add_filter('authenticate', 'exlog_auth', 10, 3); }Let me know if you try it π
- This reply was modified 5 years, 8 months ago by tbenyon.
Forum: Plugins
In reply to: [External Login] Conflict with other plugin (Logged in)Hey @danilocubrovic,
As I’m sure you will understand, compatibility with other plugins and other code is beyond the scope of the support forum.
I imagine it is due to both plugins using the
authenticatehook.I have one suggestion which is find where the above hook is called in both plugins.
In External Login the line looks like this:
add_filter('authenticate', 'exlog_auth', 10, 3);It can be found in
login/authenticate.php.The
10in this case represents the priority. I would suggest first making it lower than the number used in your other plugin and testing. Then make it higher than the number used in the other plugin and test.If neither of these work the only other suggestion I have would require you modifying one of the plugins to call the functionality of the other plugin at the correct point in the flow. This would be a chunk of custom work and if you’re not able to do this your self then you would have to pay for a developer to do this work for you.
Let me know how you get on,
Thanks,
Tom
Forum: Plugins
In reply to: [External Login] Bypass ExternalDB for WordPress AdminHey @stezter,
Thanks for getting in contact and flagging this issue.
Can you please double check that you haven’t got ‘disable local login’ ticked in the admin area.
If it is not ticked the plugin SHOULD try to login on the external DB and then if it fails to connect, try to login using the WordPress DB.
I believed this to be working but I will have time this weekend to try and replicate this and rectify the issue. I wonder if it’s the migration mode preventing this functionality for some reason.
Keep me posted and I’ll get back to you at latest Sunday with an update.
Thanks,
Tom π
Forum: Reviews
In reply to: [External Login] Easyest way to use external database to log in WordPressHey @pwozniak89,
I really appreciate you taking the time to write such a thoughtful review. Itβs really appreciated.
Tom π
Forum: Plugins
In reply to: [External Login] Drupal 7 hashI have solved it by adding drupalβs passord.inc file
GREAT IDEA!!!
I’m sure others will find it useful so thanks for sharing back here.
If it all works Iβd be grateful if you could write a review or even buy me a beer.
Thanks,
Tom π
Forum: Plugins
In reply to: [External Login] Pulling additional dataHey @sovrgn,
I guess the important bit that I’m curious by in your logs is what would come from this:
error_log(β-------------EXLOG-START------------------β); error_log(var_export($exlog_user_data, true));That second line would output all available data from your users table that it received. Can you make sure that
tokenscoreis an available property at this point.If you can’t see it in there I speculate you’re either:
- Not writing
tokenscorecorrectly. Maybe it is something liketoken_scoreortokenScore tokenscorefield does not exist in your users table in your database. Maybe it is in another table?
Let me know,
Thanks,
Tom π
Forum: Plugins
In reply to: [External Login] Can’t log inHey @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
π
Forum: Plugins
In reply to: [External Login] Drupal 7 hashHey @danilocubrovic,
It certainly can but because it appears Drupal uses a very custom approach to validate passwords, you would have to give the plugin the logic of validating your passwords.
This can be achieved by utilising this logic with the plugins
exlog_hook_filter_authenticate_hash.You can find documentation on how to use the hook in the FAQ section under the title “What hooks are available in the External Login flow?”.
You’ll need to do the dev work in making this work yourself (or find a developer who’s willing to write this custom implementation for you).
I’m going to mark this as resolved as I think I’ve answered your question but if you have any additional questions on how to use the hook or the plugin please don’t hesitate to get back to me. π
Thanks @danilocubrovic,
Tom π
Forum: Plugins
In reply to: [External Login] Can’t log inHey @pwozniak89,
I can ensure you that your English is way better than my French! π
Great that the test connection is working!
When I try to connect my WordPress with a login/password in external DB it seems to work but nothing happen
This is a new one that I’ve never had reported. I presume you mean that it is redirecting you to the admin panel when you say it seems to work?
There are three next steps:
- Disable ALL other plugins to ensure that it is not another plugin that is preventing this from working
- Share your error logs so we can see if there is anything in there that indicicates what is going on
- Ensure this is not a multisite as the plugin has not been tested on it
Thanks,
Tom
Forum: Reviews
In reply to: [External Login] Awesome PluginThanks for taking the time to write a review @sovrgn.
It’s appreciated π