• Resolved monkeydisko

    (@monkeydisko)


    Hi Tom,
    I’ve just bought you a beer. Exactly the plugin I was looking for, thank you very much!
    One question:
    I would like to block users who have not yet confirmed their e-mail address. I have a column ‘email_verified_at’ in my external users database for this purpose. It contains either a date or nothing (NULL).
    In the settings for ‘Exclude Users (BETA)’ I have entered ‘email_verified_at’ and left value empty. However, users with an unconfirmed account are still logged in.
    Am I doing something wrong?

    Thank you!
    Sascha

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

    (@tbenyon)

    Hey there Sascha,

    I’ve not worked on this plugin for some time so apologies that my answer may not be perfect.

    As that is a beta feature it may not work, however it may not work well with the empty state.

    What I would be more confident would work would be the exlog_hook_filter_custom_should_exclude hook. Here’s the notes on it from the documentation:

    - exlog_hook_filter_custom_should_exclude

    This hook allows you to add custom logic to exclude users.

    It provides you with all the data for the user that is stored in the external database users table.
    If you return
    true (or a string - see below regarding custom error messages) from this function it will prevent the
    user logging in, and returning false will bypass this exclusion.

    For example, let's say your external users table had a field called expiry which stored a date. In this example we
    want to block users if they login after their expiry date.

    Adding the following to your functions.php would achieve this:

    <br>function myExlogCustomExcluder($userData) {<br>return strtotime($userData['expiry']) < strtotime('now');<br>}<br>add_filter('exlog_hook_filter_custom_should_exclude', 'myExlogCustomExcluder', 10, 1);<br>

    Alternatively if you provide a string the user will be blocked and the string will be used as the error for the user.
    <br>function myExlogCustomExcluder($userData) {<br>return strtotime($userData['expiry']) < strtotime('now') ? 'Your account has expired' : false;<br>}<br>add_filter('exlog_hook_filter_custom_should_exclude', 'myExlogCustomExcluder', 10, 1);<br>

    The below code is what I imagine would work for you but I haven’t done any testing.

    function myExlogCustomExcluder($userData) {
    return empty($userData['email_verified_at') ? 'Your e-mail has not been verified' : false;
    }

    add_filter('exlog_hook_filter_custom_should_exclude', 'myExlogCustomExcluder', 10, 1);
    Plugin Author tbenyon

    (@tbenyon)

    … and I forgot to say – Thank you for the beer ??

    Thread Starter monkeydisko

    (@monkeydisko)

    Thanks, Tom! The Code you provided is working for me. ??
    A closing bracket was missing empty($userData['email_verified_at']), but otherwise it works exactly as it should.

    Thank you very much!

    Plugin Author tbenyon

    (@tbenyon)

    Fantastic news. Good luck with your project.

    If you get a minute to write a review I’d be very grateful.

    Thread Starter monkeydisko

    (@monkeydisko)

    Done. ??
    Thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.