Viewing 4 replies - 1 through 4 (of 4 total)
  • So is there a better way to do it…

    Since you asked… why don’t you just loop through your csv file ( either line by line or read it into an array ), add the users, and be done with it?

    Thread Starter zeridon

    (@zeridon)

    One of the purposes is relatively easy filtering of inactive members. I don’t want to import all of them or i will be stuck with the task of cleaning them. Just by having this i can leave the plugin active for 6 – 8 months and after that just shut it off.

    Drop this in you theme’s functions.php and try to log in.

    function test_wp_auth() {
      print_r(get_defined_vars());
      exit; // sometime needed; sometimes not
    }
    add_action('wp_authenticate','test_wp_auth');

    Now you know what variables you have available.

    However, I’d still not do it the way are doing it. It just seems like more work to me to interrupt the login process to add users dynamically. …could just be a personality glitch 🙂 I’d add all the users in one shot a simple ‘last_login’ tracker like this:

    function my_user_last_login($login) {
        global $user_ID;
        $user = get_userdatabylogin($login);
        update_usermeta( $user->ID, 'my_user_last_login', time() );
    }
    add_action('wp_login','my_user_last_login');

    Then after six months or so remove any users who haven’t logged in.

    Thread Starter zeridon

    (@zeridon)

    Thanks for the hint, didn’t knew about get_defined_vars

    The tracker idea is nice and will also implement it as it will be good for cleaning up dead souls.

    Additionally i stumbled on something minor. If user_nicename is not in latin it get’s filtered out (i.e. set to empty).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to authenticate against CSV file’ is closed to new replies.