Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webdados/2ee182178812bc18b54df3f97086c185 to your computer and use it in GitHub Desktop.
Save webdados/2ee182178812bc18b54df3f97086c185 to your computer and use it in GitHub Desktop.
Change the label for the autocomplete user results no the Shop as Client for WooCommerce plugin
<?php
add_filter(
'shop_as_client_autocomplete_user_label',
function ( $label, $user_id, $display_name, $user_email ) {
// Get the user
$user = get_user( $user_id );
$name_to_display = html_entity_decode( $user->display_name, ENT_QUOTES, 'UTF-8' );
// Use same label but with $name_to_display as the name
return sprintf(
__( 'Cust. #%1$d: %2$s - %3$s', 'shop-as-client-pro' ),
$user_id,
$name_to_display,
$user_email
);
},
10,
4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment