1<?php
2/**
3 * WP_User_Request class.
4 *
5 * Represents user request data loaded from a WP_Post object.
6 *
7 * @since 4.9.6
8 */
9#[AllowDynamicProperties]
10final class WP_User_Request {
11 /**
12 * Request ID.
13 *
14 * @since 4.9.6
15 * @var int
16 */
17 public $ID = 0;
18
19 /**
20 * User ID.
21 *
22 * @since 4.9.6
23 * @var int
24 */
25 public $user_id = 0;
26
27 /**
28 * User email.
29 *
30 * @since 4.9.6
31 * @var string
32 */
33 public $email = '';
34
35 /**
36 * Action name.
37 *
38 * @since 4.9.6
39 * @var string
40 */
41 public $action_name = '';
42
43 /**
44 * Current status.
45 *
46 * @since 4.9.6
47 * @var string
48 */
49 public $status = '';
50
51 /**
52 * Timestamp this request was created.
53 *
54 * @since 4.9.6
55 * @var int|null
56 */
57 public $created_timestamp = null;
58
59 /**
60 * Timestamp this request was last modified.
61 *
62 * @since 4.9.6
63 * @var int|null
64 */
65 public $modified_timestamp = null;
66
67 /**
68 * Timestamp this request was confirmed.
69 *
70 * @since 4.9.6
71 * @var int|null
72 */
73 public $confirmed_timestamp = null;
74
75 /**
76 * Timestamp this request was completed.
77 *
78 * @since 4.9.6
79 * @var int|null
80 */
81 public $completed_timestamp = null;
82
83 /**
84 * Misc data assigned to this request.
85 *
86 * @since 4.9.6
87 * @var array
88 */
89 public $request_data = array();
90
91 /**
92 * Key used to confirm this request.
93 *
94 * @since 4.9.6
95 * @since 6.8.0 The key is now hashed using wp_fast_hash() instead of phpass.
96 *
97 * @var string
98 */
99 public $confirm_key = '';
100
101 /**
102 * Constructor.
103 *
104 * @since 4.9.6
105 *
106 * @param WP_Post|object $post Post object.
107 */
108 public function __construct( $post ) {
109 $this->ID = $post->ID;
110 $this->user_id = $post->post_author;
111 $this->email = $post->post_title;
112 $this->action_name = $post->post_name;
113 $this->status = $post->post_status;
114 $this->created_timestamp = strtotime( $post->post_date_gmt );
115 $this->modified_timestamp = strtotime( $post->post_modified_gmt );
116 $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
117 $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
118 $this->request_data = json_decode( $post->post_content, true );
119 $this->confirm_key = $post->post_password;
120 }
121}
122