Skip to content

Instantly share code, notes, and snippets.

@fida02
Last active August 9, 2022 20:34
Show Gist options
  • Select an option

  • Save fida02/5fde0757eb41c18a351d4ed4bd2ba33e to your computer and use it in GitHub Desktop.

Select an option

Save fida02/5fde0757eb41c18a351d4ed4bd2ba33e to your computer and use it in GitHub Desktop.
WPMUDEV Unique customer ID Task
<?php
/**
* Unique customer ID
*
* @return string
*/
function wpmu_unique_id() {
// Get current user object
$current_user = wp_get_current_user();
// Check is user logged in
if( $current_user->exists() ) {
// Unique ID prefix
$prefix = 'wpmu-';
// User registration date and time
$registered_date_time = date( 'jis', strtotime( $current_user->user_registered ) ) ;
// User ID
$user_id = esc_html( $current_user->ID );
// Create the unique ID
$unique_id = $prefix . $registered_date_time . $user_id;
return $unique_id;
}
}
// Add shortcode [wpmu_unique_id]
add_shortcode( 'wpmu_unique_id', 'wpmu_unique_id' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment