Skip to content

Instantly share code, notes, and snippets.

@Lonsdale201
Created November 28, 2023 10:06
Show Gist options
  • Select an option

  • Save Lonsdale201/492fd40b98b47c52b8bc963b35522955 to your computer and use it in GitHub Desktop.

Select an option

Save Lonsdale201/492fd40b98b47c52b8bc963b35522955 to your computer and use it in GitHub Desktop.
JetEngine - Custom Macro - Current user email
add_action( 'jet-engine/register-macros', function(){
class Current_User_Email extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'current_user_email';
}
public function macros_name() {
return 'Current user email';
}
public function macros_callback( $args = array() ) {
$user = wp_get_current_user();
if ( $user && 'WP_User' === get_class( $user ) ) {
return $user->user_email;
}
return 'User not logged in or email not found';
}
public function macros_args() {
return array();
}
}
new Current_User_Email();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment