Created
June 18, 2018 09:59
-
-
Save anthonybudd/2c12deaf3200248a26e174be7e4f5af5 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
<?php | |
Class Data extends WP_Model{ | |
public $postType = 'data'; | |
public $attributes = [ | |
'foo', | |
'author', | |
]; | |
public $filter = [ | |
'author' | |
]; | |
public function _filterAuthor(){ | |
return get_user_by('ID', $this->author); | |
} | |
public function inserting(){ | |
$this->author = get_current_user_id(); | |
} | |
} | |
Data::register(); | |
$data = new Data | |
$data->foo = 'bar'; | |
$data->save(); | |
$data = Data::find(1); | |
$data->author; // WP_User |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment