• Resolved kayapati

    (@kayapati)


    I would like to make it as a shortcode for this hooks, is it possible?

    do_action("um_profile_content_main", $args);

    I want to make the profile page like this: https://lwcasting.co.uk/performer/praise/

    So inroder to make the profile page like above I badly need the shortcode which I can enter in profile form.

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

    (@champsupertramp)

    Hi @kayapati

    You can use this code to enable shortcode that display each User Meta to your custom template:

    /**
     * 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' );

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @kayapati

    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,

    Thread Starter kayapati

    (@kayapati)

    Thank you, I did not notice this, its very useful to me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Profile Meta main shortcode’ is closed to new replies.