Created
November 28, 2023 10:06
-
-
Save Lonsdale201/492fd40b98b47c52b8bc963b35522955 to your computer and use it in GitHub Desktop.
JetEngine - Custom Macro - Current user email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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