• Resolved anemos2k

    (@anemos2k)


    Hi Tom,

    I am thinking of implementing your plugin on my site and I have a small question that I was hoping you could answer.

    Is there a possibility to detect a flag like active/inactive on the external database and deactivate/activate accordingly the users created on the local WordPress database? Or if I assign a specific user role in the external db, can this be used to disallow access locally in WordPress? If any of the above scenarios are not possible, any ideas how I could prevent a deactivated user on the external database to login in WordPress?

    Please let me clarify: On the external database, users never get deleted, they are only marked as deactivated and this leads me to question the fact that since a user account and a password DO EXIST in the external database how do I prevent that this user gets created and be allowed to log in locally in WordPress?

    By the way, the suggestion that you made on another user to allow adding/modifying part of the SQL query on the external database is very, very interesting!

    Thanks in advance for your input!
    Panos

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

    (@tbenyon)

    Hey @anemos2k,

    I find it hard to choose which features to add and how to implement them. My goals are:
    – To not overcomplicate the user experience of the plugin
    – To prioritise features that will be of use to as many users as possible

    I welcome your opinion in making this decision.

    I’ve had another user that had a feature request similar to yours but you have flagged one downside to it.

    The feature would be to allow you to choose another field in the external user table that represented if the user was allowed to log in or not. The complication comes if there are more than two states in that field. I would have to allow the UI to accept “if this is true and not this” etc.

    One downside would be that if a user logged in once, they had that field changed, the external db was offline and the WP data was being used this would not get updated. This is the nature of all systems getting out of sync. I could make it so that when a user logs in and they are not allowed to login – if a user is in the WP database – delete them.

    Or I could make it so certain roles from the external login are not allowed to login. I could add “No login” instead of a role to the role mappings section and bloke those roles.

    Advice welcome on which approach!

    Regarding the SQL query, my plan was to not allow the user to modify the authentication query for logging in, but to write a PHP function that developers would be able to call on pages to query the external database. It would use the credentials stored in the plugin but allow a developer to easily grab more data and I could just return the results as a PHP array.

    Is this what you had in mind or not really?

    Thanks,

    Tom

    • This reply was modified 6 years, 4 months ago by tbenyon. Reason: Clarity and typos corrected
    Thread Starter anemos2k

    (@anemos2k)

    Hi Tom,

    Thank you for your prompt response!

    I do believe that the problem described above is a general one. Many developers choose not to delete completely users but to just deactivate them. In that sense, they can always refer to the user’s historic data without creating orphan records in the database.

    Now back to the plugin.
    I think that adding an optional field could solve the problem. All users existing in the external database would be granted a login and be copied on the local db except if the plugin user has specified that there is an extra field on the external db defining the user’s login capability or not. This extra field would have to have just two states (as you very well mention), true/false or 1/0, true or 1 allowing the user to login, false or 0 disallowing it.

    The same functionality could also be implemented by the user role defined in the external db (as you also very well mentioned). In that case, on the plugin settings on the role pairing screen, you could present just a check box next to the drop-down list with the external db roles where the user would check the roles that do not grand a WordPress login.

    In both scenarios, those users should not be copied on the local db and should be removed or better marked as inactive if they were already existing there.

    Regarding the SQL query, I think that it could be useful. However, since it would require a developer to deal with it (and the returned PHP array), it would appeal to a much more limited audience. Maybe you should consider it as a possible add-on but definitely not being part of the main distribution of the plugin and the problem that you are trying to solve which is: Allow authentication using an external database.

    Thanks again for taking the time to look into this!

    Best regards
    Panos

    Plugin Author tbenyon

    (@tbenyon)

    Hey @anemos2k,

    Thanks for your thoughts. I agree with most of what you’ve said but I think in regard to blocking roles, I’ll probably just add to the list of roles to map to block login so it’s all tied in to the drop down. Partly because I can develop that quicker and may iterate a change to the UI later.

    It sounds like the checking an additional field is of more importance to you at this stage so I’ll start work on that first.

    I think I’ll implement this with a separate section called “Exclude Users”.
    It will have:
    – A checkbox to activate the functionality
    – A box to type the field name where the blocking state is stored
    – A text field to type the value that should be blocked
    – EXTENSION – Make the text field repeatable so multiple values can be blocked. E.g. if they are marked as “deleted” or “banned”

    Starting work on this now. Let me know if you are not happy with the above.

    Tom

    Thread Starter anemos2k

    (@anemos2k)

    Hi Tom,

    sounds great! I’m already excited! ??

    Panos

    Plugin Author tbenyon

    (@tbenyon)

    Hey @anemos2k,

    Family life has got in the way. So just wanted to apologise and give an update at least.

    The functionality to exclude when logging in was very easy and I implemented that very quickly . . . however, trying to get a generic repeater field system for my front end that I can re-use is a bit of a bigger job but I’m making progress.

    If you have a deadline I could write you something that would allow you to add some code to your functions.php file or wp-config.php that would allow you to add this functionality that way, Might be a fix at least until I can finish making it more user friendly in the admin area form.

    If you’ve got a deadline and this would help let me know. If not I’ll plod on for now.

    Thanks,

    Tom

    Thread Starter anemos2k

    (@anemos2k)

    Hi Tom,

    Family life tends to do that, it’s perfectly normal! ??

    I think that I can delay the WordPress user login functionality till there’s an admin section that deals with the described problem.

    Again, thank you for looking into that as well as suggesting a part-time solution in case I had a deadline. You are very considerate! In case I start to run out of time I might send you a quick message asking for the possible changes in functions.php or wp-config.php, if you don’t mind.

    Best regards
    Panos

    Plugin Author tbenyon

    (@tbenyon)

    Hey @anemos2k,

    No problem at all and thanks for your understanding.

    Just let me know a few days before if you get close to needing it and I’ll throw that functionality in for you.

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hey @anemos2k,

    I’ve got a working prototype relating to this. This allows you to give the name of another field that and a set of values for that field that would block a user.

    For example, I want to look in the “status” field and block any users who’s status is “blocked” or “sat out”.

    Would you be able to help by downloading the code from GitHub and testing it before I make it live?

    https://github.com/tbenyon/wordpress_external_login_plugin/archive/eb0a1e4b67ea4fa3d21d4923b03e24f12b3c1a07.zip

    Any feedback would be very welcome!

    If this isn’t possible – it’s no problem ??

    Next I’m going to make it so that certain roles can block login also.

    Tom

    Thread Starter anemos2k

    (@anemos2k)

    Hi @tbenyon,

    Thank you for your efforts! First of all Happy New Year to you and your family!!!

    I downloaded the plugin and installed it for testing. The Database Types according to the drop down are “MySQL and PostgreSQL”. My DB is an Azure based MS SQL. Are you planning on adding support for that or are those two the only Databases supported by the plugin?

    Other than that, I do get an error 999 at the bottom of the plugin settings section:
    X
    Loading…
    ERROR: 999

    Best regards
    Panos

    Plugin Author tbenyon

    (@tbenyon)

    Hey Panos,

    I had a look at getting MS SQL setup once but struggled to see how to get a local version working on my Mac so I could do testing. I don’t suppose you’ve done this before or know of a free service I could use to do some testing on? (Don’t give me access to something you own as this breaks WP code of practice).

    If you’re still keen to use the plugin I’ll have another look at this!

    Regarding he 999 Error, this should only happen if you click the test button. Is that what made it appear?

    Thanks,

    Tom

    Thread Starter anemos2k

    (@anemos2k)

    Hi Tom,

    You are correct about your Test button assumptions. However, on refreshing the page, shouldn’t this error disappear?

    Here are two links helping with the MS SQL installation on a MAC. The first one is the oldest one and uses Virtual Box (need to install Windows on it and then SQL server)
    https://database.guide/how-to-install-sql-server-on-a-mac-with-virtualbox/
    However, the second is using Docker container and MS SQL for Linux!
    https://database.guide/how-to-install-sql-server-on-a-mac/
    The second article also provides links for a free SQL management tool under Mac.

    I would still be very interested in implementing your plugin functionality in my environment.

    Best regards
    Panos

    Plugin Author tbenyon

    (@tbenyon)

    Oooooh That second link sounds awesome!

    It’s on my Trello board! If you have a hard deadline you’d need this by let me know and I can tell you whether it’s feasible.

    Tom

    I am testing the beta as I have two fields in the external db that I’d like to exclude users. but when I go to save these settings they are not saved. I don’t have any errors indicating why.

    • This reply was modified 6 years, 1 month ago by xprojectsx.
    Plugin Author tbenyon

    (@tbenyon)

    Hey @xprojectsx,

    Are you still experiencing this problem?

    Could you tell me:

    • Which browser you’re using
    • Look at the browser console to see if there are any errors
    • Look in your database wp_options table and tell me what is stored in the field named “exlog_exclude_users_field_name_repeater”

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    @xprojectsx – one more thing . . .

    Could you do a force refresh in your browser.

    Information on how to do this can be found here:
    https://www.getfilecloud.com/blog/2015/03/tech-tip-how-to-do-hard-refresh-in-browsers/#.XDtnWc-eRZI

Viewing 15 replies - 1 through 15 (of 50 total)
  • The topic ‘Active/Inactive Users’ is closed to new replies.