I'd like to determine how many times a user has logged in. Does WordPress retain that information or will I have to add a db entry every time they log-in?

if(is_user_logged_in() && ($logged_in_times == 2)) {
    // do something

I don't think so. You will need to do something like this (untested):

add_action("wp_login", "my_login_function");

function my_login_function($username){
   $userdata = get_user_by('login', $username);
   $n = get_user_meta($userdata->ID, "my_login_counter", true);
   if (! is_numeric($n)) $n = 0;
   $n = intval($n) + 1;
   update_user_meta($userdata->ID, "my_login_counter", $n);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.