This code works great when put directly into the content of a page.
<font color=#ff0000>
<?php global $current_user;
get_currentuserinfo();
echo $current_user->display_name . "\n";
echo 'Level: ' . $current_user->level . "\n <br>";
?>
</font>
Result shows 'Sam level 65'
However, when I convert it to a shortcode and try to replace echo with return, wordpress breaks, all screens go blank. This is an example of what i've tried:
// Add Shortcode
function custom_shortcode() {
// Code
<font color=#ff0000>
<?php global $current_user;
get_currentuserinfo();
$output = $current_user->display_name . "\n";
$output .= 'Level: ' . $current_user->level . "\n <br>";
return $output;
?>
</font>
}
add_shortcode( 'userlevel', 'custom_shortcode' );
Any idea where I'm going wrong?
Thank you in advance!