# profile-builder/3.9.8/admin/advanced-settings/includes/shortcodes/usermeta.php

User Profile Builder – Beautiful User Registration Forms, User Profiles &amp; User Role Editor, version 3.9.8. 56 lines.

- Page: https://pluginprobe.com/plugins/profile-builder/3.9.8/code/admin/advanced-settings/includes/shortcodes/usermeta.php
- Raw: https://pluginprobe.com/plugins/profile-builder/3.9.8/raw/admin/advanced-settings/includes/shortcodes/usermeta.php
- Modified: 2023-02-13T11:35:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/profile-builder/3.9.8/code/admin/advanced-settings/includes/shortcodes/usermeta.php#L10-L20`.

```php
<?php

add_shortcode('user_meta', 'wppb_toolbox_usermeta_handler');
function wppb_toolbox_usermeta_handler( $atts, $content=null){

	if ( !isset( $atts['user_id'] ) ){
		$user = wp_get_current_user();
		$atts['user_id'] = $user->ID;
	}
	if ( !isset( $atts['size'] ) ){
		$atts['size'] = '50';
	}
	if ( !isset( $atts['pre'] ) ) {
		$atts['pre'] = '';
	}
	if ( !isset( $atts['post'] ) ) {
		$atts['post'] = '';
	}
	if ( !isset( $atts['wpautop'] ) ) {
		$atts['wpautop'] = '';
	}

	if( in_array( $atts['key'], array( 'user_pass', 'user_activation_key' ) ) )
		return;

	$user = new WP_User( $atts['user_id'] );

	if ( !$user->exists() ) return;

	if ( !array_key_exists( 'key', $atts ) ) return;

	if( $atts['key'] == 'avatar' ){
		return $atts['pre'] . get_avatar( $user->ID, $atts['size']) . $atts['post'] ;
	}

    if( $atts['key'] === 'id' ){
        $atts['key'] = 'ID';
    }

	if ( $user->has_prop( $atts['key'] ) ){

		if ($atts['wpautop'] == 'on'){
			$value = wpautop( $user->get( $atts['key'] ) );
		} else {
			$value = $user->get( $atts['key'] );
		}

	}

	if (!empty( $value )){
		return $atts['pre'] . $value . $atts['post'] ;
	}

	return;
}

```
