Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Created June 18, 2018 09:59
Show Gist options
  • Save anthonybudd/2c12deaf3200248a26e174be7e4f5af5 to your computer and use it in GitHub Desktop.
Save anthonybudd/2c12deaf3200248a26e174be7e4f5af5 to your computer and use it in GitHub Desktop.
<?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