🦾 You could save time! Try Wendy, the FREE AI WordPress Developer.
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)
Reorder the WooCommerce columns to the end
// Sort columns after they have all been added by plugins.
function custom_wc_column_order($columns) {
if (!empty($columns['private_user_note'])) {
// Grab the note column.
$note_column = $columns['private_user_note'];
// Remove it from the current location in the array.
unset($columns['private_user_note']);
// Re-set it at the end.
$columns['private_user_note'] = $note_column;
}
return $columns;
}
add_filter('manage_edit-shop_order_columns', 'custom_wc_column_order', 999);
Code language: PHP (php)