The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Shortcode to return the User's domain from their email address


This Discussion is public


function extract_domain_func(){
$current_user = wp_get_current_user();
$email = $current_user->user_email;
if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
// split on @ and return last value of array (the domain)
$domain = array_pop(explode('@', $email));
return $domain;

Usage [users-email-domain]

Discussion closed.