Skip to content

Instantly share code, notes, and snippets.

@brettp
Created August 12, 2011 16:32
Show Gist options
  • Save brettp/1142415 to your computer and use it in GitHub Desktop.
Save brettp/1142415 to your computer and use it in GitHub Desktop.
Elgg plugin to count number of times a user has logged in
<?php
/**
* Hook into the login, user event and increment the login count metadata.
*
* @param string $event
* @param string $type
* @param ElggUser $user
*/
function login_count($event, $type, $user) {
$login_count = $user->login_count;
$login_count++;
$user->login_count = $login_count;
if ($login_count == 10) {
forward("url-to-forward-to");
}
}
register_elgg_event_handler('login', 'user', 'login_count');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment