Created
February 4, 2012 09:31
-
-
Save psynewave/1736746 to your computer and use it in GitHub Desktop.
Wordpress User Info Short Code
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
// display content to logged in users via shortcode | |
function member_only($atts, $content = null) { | |
if (is_user_logged_in()) | |
return '<div class="memberContent">' . do_shortcode($content) . '</div>'; | |
return ''; | |
} | |
add_shortcode('member_only', 'member_only'); | |
// display content to logged out users via shortcode | |
function non_member($atts, $content = null) { | |
if (!is_user_logged_in()) | |
return '<div class="nonMemberContent">' .do_shortcode($content) . '</div>'; | |
return ''; | |
} | |
add_shortcode('non_member', 'non_member'); | |
//display user id via shortcode | |
function member_id(){ | |
$current_user = wp_get_current_user(); | |
$member = $current_user->user_login; | |
return $member; | |
} | |
add_shortcode('member_id', 'member_id'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment