PHP snippet: get logged in username and show it on the WooCommerce checkout page in a billing field
add_action('woocommerce_after_checkout_billing_form', 'bbloomer_get_logged_in_username');
function bbloomer_get_logged_in_username( $checkout ) {
$current_user = wp_get_current_user();
$getmemid = $current_user->user_login;
woocommerce_form_field( 'memb_id', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Label'),
'required' => 'true',
'placeholder' => __('Placeholder'),
), $getmemid);
}
No comments:
Post a Comment