Created
February 25, 2019 23:51
-
-
Save tradesouthwest/11eda7954d05093899b79ed963001a93 to your computer and use it in GitHub Desktop.
Only show nickname if not admin in a wordPress plugin
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
<?php | |
/** | |
* Only show nickname if not admin | |
* | |
* @since 1.0.0 | |
* | |
* TODO option to toggle | |
*/ | |
function vertycal_maybe_show_nickname( $author ) | |
{ | |
$author = wp_get_current_user(); | |
if( current_user_can('administrator') ) | |
{ $hrdscls = 'vrctl-hidden'; } | |
else { $hrdscls = 'vrtcl-block'; } | |
ob_start(); | |
echo '<h4>' . esc_html__( 'Account: ', 'vertycal' ) | |
. '<span class="' . esc_attr( $hrdscls ) . '">' . $author->nickname . '</span>' . '</h4>'; | |
$output = ob_get_clean(); | |
return $output; | |
} | |
//usage (inline): echo vertycal_maybe_show_nickname( $author ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment