Created
May 6, 2019 20:12
-
-
Save tradesouthwest/3b4062ed5502f1c77d74dde3c7500d0c to your computer and use it in GitHub Desktop.
Shortcode to print all user meta on a wordpress page.
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 | |
/** | |
* Get list of all user meta | |
* @package WordPress | |
* @uses shortcode [bnsw_userprint="user_id"] Or whatever name you register | |
*/ | |
function bnswfields_user_list_meta($atts) | |
{ | |
if ( !isset( $atts['user_id'] ) ){ | |
$user = wp_get_current_user(); | |
$atts['user_id'] = $user->ID; | |
} | |
ob_start(); | |
print( '<h4>User Meta</h4>' ); | |
$user_info = get_user_meta($atts['user_id']); | |
echo '<pre>'; | |
print_r($user_info); | |
echo '</pre>'; | |
$output = ob_get_clean(); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment