Skip to content

Commit

Permalink
Added two new function: user_exsist_by_id() and user_exsist_by_email()
Browse files Browse the repository at this point in the history
  • Loading branch information
c2pdev committed Oct 31, 2014
1 parent 3f65c5f commit c80bd10
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,42 @@ public function is_banned($user_id) {
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
Expand Down

0 comments on commit c80bd10

Please sign in to comment.