Skip to main content
updated according to comment
Source Link
Bainternet
  • 67.7k
  • 8
  • 131
  • 188

Here is the simplest shortcode that will do the job for you

add_shortcode('USER_META', 'user_meta_shortcode_handler');
/**
 * User Meta Shortcode handler
 * usage: [USER_META user_id=1 meta="first_name"]
 * @param  array $atts   
 * @param  string $content
 * @return stirng
 */
function user_meta_shortcode_handler($atts,$content=null){
    return esc_html(get_user_meta($atts['user_id'], $atts['meta'], true));
}

USAGE:

[USER_META user_id=1 meta="first_name"]
[USER_META user_id=1 meta="last_name"]

Here is the simplest shortcode that will do the job for you

add_shortcode('USER_META', 'user_meta_shortcode_handler');
/**
 * User Meta Shortcode handler
 * usage: [USER_META user_id=1 meta="first_name"]
 * @param  array $atts   
 * @param  string $content
 * @return stirng
 */
function user_meta_shortcode_handler($atts,$content=null){
    return get_user_meta($atts['user_id'], $atts['meta'], true);
}

USAGE:

[USER_META user_id=1 meta="first_name"]
[USER_META user_id=1 meta="last_name"]

Here is the simplest shortcode that will do the job for you

add_shortcode('USER_META', 'user_meta_shortcode_handler');
/**
 * User Meta Shortcode handler
 * usage: [USER_META user_id=1 meta="first_name"]
 * @param  array $atts   
 * @param  string $content
 * @return stirng
 */
function user_meta_shortcode_handler($atts,$content=null){
    return esc_html(get_user_meta($atts['user_id'], $atts['meta'], true));
}

USAGE:

[USER_META user_id=1 meta="first_name"]
[USER_META user_id=1 meta="last_name"]
Source Link
Bainternet
  • 67.7k
  • 8
  • 131
  • 188

Here is the simplest shortcode that will do the job for you

add_shortcode('USER_META', 'user_meta_shortcode_handler');
/**
 * User Meta Shortcode handler
 * usage: [USER_META user_id=1 meta="first_name"]
 * @param  array $atts   
 * @param  string $content
 * @return stirng
 */
function user_meta_shortcode_handler($atts,$content=null){
    return get_user_meta($atts['user_id'], $atts['meta'], true);
}

USAGE:

[USER_META user_id=1 meta="first_name"]
[USER_META user_id=1 meta="last_name"]