-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWPUserData.php
More file actions
47 lines (42 loc) · 1.02 KB
/
WPUserData.php
File metadata and controls
47 lines (42 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace DevonSample;
use BlueFission\DevObject;
class WPUserData extends DevObject {
protected $user_id;
/**
* Sets the wordpress user id for this operation
* @param int $id the id for the related Wordpress user
*/
public function setID( $id ) {
$this->_user_id = $id;
}
/**
* Loads the matching meta data for the currently set user id
* @return boolean true on success and false on failure
*/
public function load() {
if ( ! defined( 'WPINC' ) || ! $this->_user_id ) {
return false;
}
$meta = get_post_meta( $this->_user_id );
foreach ( $this->_data as $key ) {
$this->_data[$key] = $meta[$key];
}
return true;
}
/**
* Save function stores class data as Wordpress meta data
* @return boolean true on success and false on failure
*
*/
public function save() {
if ( ! defined( 'WPINC' ) || ! $this->_user_id ) {
return false;
}
$status = false;
foreach ( $this->_data as $key=>$value ) {
$status = update_user_meta($this->_user_id, $key, $value);
}
return $status;
}
}