Ticket #556 (closed Feature Request: fixed)
user exists by id, email or username
| Reported by: | littfed | Owned by: | Shadowhand |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.2 |
| Component: | Modules:Auth | Version: | SVN HEAD |
| Keywords: | user exists | Cc: |
Description
I use Auth module, but I need function, to check if user exists in database not only by username.
I patch /models/user.php and add function exists.
/**
* Tests if a user exists in the database.
*
* @param string username or email or id to check
* @return bool
*/
public function exists($id)
{
if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id))
{
$where = valid::email($id) ? 'email' : 'username';
} else $where = 'id';
return (bool) self::$db->where($where, $id)->count_records('users');
}
Maybe, it will be interesting for someone else?
Change History
Note: See
TracTickets for help on using
tickets.
