Created
February 28, 2017 21:02
-
-
Save buddycore/eb7ae29bcd777d899b28506857c15796 to your computer and use it in GitHub Desktop.
Auth Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(!function_exists('is_logged_in')) : | |
| function is_logged_in() { | |
| $CI =& get_instance(); | |
| if($CI->session->userdata('is_logged_in') == FALSE) : | |
| return FALSE; | |
| else : | |
| return TRUE; | |
| endif; | |
| } | |
| function is_logged_in_admin() { | |
| $CI =& get_instance(); | |
| if($CI->session->userdata('role') === 'admin') : | |
| return TRUE; | |
| else : | |
| return FALSE; | |
| endif; | |
| } | |
| function get_admin_user_id(){ | |
| $CI =& get_instance(); | |
| $CI->db->limit(1); | |
| $CI->db->where('role', 'admin'); | |
| $CI->db->order_by('id', 'asc'); | |
| $query = $CI->db->get('users'); | |
| if($query->num_rows() > 0) : | |
| $query = $query->result(); | |
| return $query[0]->id; | |
| else : | |
| return FALSE; | |
| endif; | |
| } | |
| endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment