Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @richard_vermeer

    You can use this code snippet to add custom user data via shortcode:

    /**
     * Returns a user meta value
     * Usage [um_user user_id="" meta_key="" ] // leave user_id empty if you want to retrive the current user's meta value.
     * meta_key is the field name that you've set in the UM form builder
     * You can modify the return meta_value with filter hook 'um_user_shortcode_filter__{$meta_key}'
     */
    function um_user_shortcode( $atts ) {
    	$atts = extract( shortcode_atts( array(
    		'user_id' => get_current_user_id(),
    		'meta_key' => '',
    	), $atts ) );
    	
    	if ( empty( $meta_key ) ) return;
    	
    	if( empty( $user_id ) ) $user_id = get_current_user_id(); 
        
        $meta_value = get_user_meta( $user_id, $meta_key, true );
        if( is_serialized( $meta_value ) ){
           $meta_value = unserialize( $meta_value );
        } 
        if( is_array( $meta_value ) ){
             $meta_value = implode(",",$meta_value );
        }  
        return apply_filters("um_user_shortcode_filter__{$meta_key}", $meta_value );
     
    }
    add_shortcode( 'um_user', 'um_user_shortcode' );

    For example, if you want to display the Full name of a member, you can try this shortcode: [um_user user_id="123" meta_key="display_name" ]

    Regards,

    kayapati

    (@kayapati)

    I have added the above code in function.php and added this shortcode in UM profile form

    [um_user user_id=”” meta_key=”” ]

    It’s getting blank, any thing missed, can you recheck it and confirm?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @kayapati

    It won’t display anything because the Meta Key is blank. Meta Key value is required in the shortcode.

    Regards,

    Thread Starter richard_vermeer

    (@richard_vermeer)

    Hi Champ,

    Thank you very much for your reply. I will look into this. The function needs to added to the functions.php file, correct?

    Regards,

    Richard

    kayapati

    (@kayapati)

    Champ Thank you I got it.

    kayapati

    (@kayapati)

    richard_vermeer yes, you need to add the code in function.php

    Thread Starter richard_vermeer

    (@richard_vermeer)

    OK, Thanks!

    kayapati

    (@kayapati)

    Sorry, I mistaken, I just blank I added the code in function.php and used this code;

    [um_user user_id=”” meta_key=”country, gender” ]

    Still getting blank.

    Even I have added this also not working:

    [um_user user_id=” ” meta_key=”country”]

    • This reply was modified 5 years ago by kayapati.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @kayapati

    If you need to show the current logged-in user’s data with the shortcode, you don’t need to add the user_id. Just keep it as [um_user meta_key=”country”]

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @richard_vermeer

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘UM and WP Job Manager and profile’ is closed to new replies.