mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-02 12:02:25 +08:00
17 lines
669 B
Text
17 lines
669 B
Text
// Add customer's full name to My Account page in WooCommerce
|
|
function display_customer_full_name() {
|
|
// Get the current user's ID
|
|
$user_id = get_current_user_id();
|
|
|
|
// Get the user's first and last name
|
|
$first_name = get_user_meta($user_id, 'first_name', true);
|
|
$last_name = get_user_meta($user_id, 'last_name', true);
|
|
|
|
// Display the full name
|
|
if ($first_name || $last_name) {
|
|
echo '<p class="woocommerce-customer-name">Welcome, ' . esc_html($first_name) . ' ' . esc_html($last_name) . '!</p>';
|
|
}
|
|
}
|
|
|
|
// Hook the function to WooCommerce My Account page
|
|
add_action('woocommerce_account_dashboard', 'display_customer_full_name');
|