Developer hooks

Accessing User Notes

User Notes are stores as an array on the user meta. The below example shows you how to output the user notes via PHP.

function custom_get_notes( $user_id ) { if ( empty( $user_id ) ) { return; } $notes = get_user_meta( $user_id, '_puri_user_note', true ); if ( empty( $notes ) || ! is_array( $notes ) ) { return; } $notes_output = ''; foreach ( $notes as $note ) { if ( ! empty( $note['content'] ) ) { $notes_output .= esc_html( $note['content'] ); } } if ( empty( $notes_output ) ) { return; } $output = '<span style="margin:20px 0px;display: block;">'; $output .= '<strong>' . __( 'Private Notes:', 'puri-user-notes' ) . '</strong>'; $output .= $notes_output; $output .= '</span>'; return $output; }
Code language: PHP (php)
Was this page helpful?