Created
March 25, 2015 03:32
-
-
Save addingama/ff9a74b256697fe65aa5 to your computer and use it in GitHub Desktop.
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
// WpUser.php model | |
<?php | |
App::uses('AppModel', 'Model'); | |
require(DIRNAME(ROOT).WP_DIR.'wp-load.php'); | |
class WpUser extends AppModel { | |
} | |
// User controller: login | |
public function login() { | |
$this->loadModel('WpUser'); | |
if($this->Auth->user()){ | |
if($this->Auth->user('role') == 'follower'){ | |
$this->redirect(array('controller' => 'users','action' => 'follower')); | |
}else{ | |
$this->redirect(array('controller' => 'users','action' => 'index')); | |
} | |
} | |
if ($this->request->is('post')) { | |
if (null == user_exists($this->data['User']['email'])) { | |
debug('null'); die; | |
} | |
if ($this->Auth->login()) { | |
// check wp user, if null then create new | |
if($this->Auth->user('role') == 'follower'){ | |
return $this->redirect(array('controller' => 'users','action' => 'follower')); | |
}else{ | |
return $this->redirect($this->Auth->redirect()); | |
} | |
} | |
$this->Session->setFlash(__('Invalid username or password, try again'),'auth_message',array('status' => 'danger'),'auth'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment