LLMS_Order::add_note( string $note, boolean $added_by_user = false )
Add an admin-only note to the order visible on the admin panel notes are recorded using the wp comments API & DB
Parameters Parameters
- $note
-
(string) (Required) Note content.
- $added_by_user
-
(boolean) (Optional) If this is an admin-submitted note adds user info to note meta. Default is false.
Default value: false
Return Return
(null|int) Null on error or WP_Comment ID of the note.
Source Source
File: includes/models/model.llms.order.php
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | public function add_note( $note , $added_by_user = false ) { if ( ! $note ) { return ; } // Added by a user from the admin panel. if ( $added_by_user && is_user_logged_in() && current_user_can( apply_filters( 'lifterlms_admin_order_access' , 'manage_options' ) ) ) { $user_id = get_current_user_id(); $user = get_user_by( 'id' , $user_id ); $author = $user ->display_name; $author_email = $user ->user_email; } else { $user_id = 0; $author = _x( 'LifterLMS' , 'default order note author' , 'lifterlms' ); $author_email = strtolower ( _x( 'LifterLms' , 'default order note author' , 'lifterlms' ) ) . '@' ; $author_email .= isset( $_SERVER [ 'HTTP_HOST' ] ) ? str_replace ( 'www.' , '' , sanitize_text_field( wp_unslash( $_SERVER [ 'HTTP_HOST' ] ) ) ) : 'noreply.com' ; $author_email = sanitize_email( $author_email ); } $note_id = wp_insert_comment( apply_filters( 'llms_add_order_note_content' , array ( 'comment_post_ID' => $this ->get( 'id' ), 'comment_author' => $author , 'comment_author_email' => $author_email , 'comment_author_url' => '' , 'comment_content' => $note , 'comment_type' => 'llms_order_note' , 'comment_parent' => 0, 'user_id' => $user_id , 'comment_approved' => 1, 'comment_agent' => 'LifterLMS' , 'comment_date' => current_time( 'mysql' ), ) ) ); do_action( 'llms_new_order_note_added' , $note_id , $this ); return $note_id ; } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.35.0 | Sanitize $_SERVER data. |
3.0.0 | Introduced. |