From c80bd1084d2361440553143df15c59c6c7a2d70c Mon Sep 17 00:00:00 2001 From: Dawid Myszczyszyn Date: Fri, 31 Oct 2014 23:39:55 +0000 Subject: [PATCH] Added two new function: user_exsist_by_id() and user_exsist_by_email() --- README.md | 19 +++++++++++++++++ application/libraries/Aauth.php | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/README.md b/README.md index b839e85..e8d71ae 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,25 @@ sorry John you will be banned :( ```php $this->aauth->ban_user(3); ``` + +You can check if the user exists in the database based on the user's email address + +```php +if($this->aauth->user_exsist_by_email('user@domain.tld')){ +//user exsist +}else{ +//user not exsist +} +``` +or user id + +```php +if($this->aauth->user_exsist_by_id(3)){ +//user exsist +}else{ +//user not exsist +} +``` Quick Start is done but thats not the end Take a look [detailed Documentation from wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index d337a65..85e6769 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -803,6 +803,42 @@ class Aauth { return FALSE; } + /** + * user_exsist_by_id + * Check if user exist by user id + * @param $user_id + * + * @return bool + */ + public function user_exsist_by_id( $user_id ) { + $query = $this->CI->db->where('id', $user_id); + + $query = $this->CI->db->get($this->config_vars['users']); + + if ($query->num_rows() > 0) + return TRUE; + else + return FALSE; + } + + /** + * user_exsist_by_email + * Check if user exsist by user email + * @param $user_email + * + * @return bool + */ + public function user_exsist_by_email( $user_email ) { + $query = $this->CI->db->where('email', $user_email); + + $query = $this->CI->db->get($this->config_vars['users']); + + if ($query->num_rows() > 0) + return TRUE; + else + return FALSE; + } + /** * Get user id * Get user id from email address, if par. not given, return current user's id