Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/20f738c6bc3f5017dc19fdb2ed950b95 to your computer and use it in GitHub Desktop.
Save champsupertramp/20f738c6bc3f5017dc19fdb2ed950b95 to your computer and use it in GitHub Desktop.
Display Specific Profile with a Shortcode on a Page
/**
* Sample usage: [um_embed_profile user_id="123" form_id="3"]
*/
add_shortcode("um_embed_profile","um_082321_embed_specific_profile");
function um_082321_embed_specific_profile( $atts ){
$atts = shortcode_atts( array(
'user_id' => get_current_user_id(),
'form_id' => 0,
), $atts );
extract( $atts );
UM()->user()->target_id = $user_id;
$value = "[ultimatemember form_id='{$form_id}']";
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
return do_shortcode( $value );
} else {
return apply_shortcodes( $value );
}
}
@kance
Copy link

kance commented Oct 2, 2021

Hey @champsupertramp, thank you for the code!
Works like a champ!!

@Harisakrami98
Copy link

Harisakrami98 commented Jul 16, 2023

hi i tried the code, but not working form me showing multiple profiles in profile tab.
here the code i added, i don't know its wrong or right? because i am new in this field. if my code is wrong please guide me the right code or just give me modified code with my user & profile id. many many thanks

/**

  • Sample usage: [um_embed_profile user_id="um_card-holder" form_id="1383"]
    */
    add_shortcode("um_embed_profile","um_082321_embed_specific_profile");
    function um_082321_embed_specific_profile( $atts ){

    $atts = shortcode_atts( array(
    'user_id' => um_card-holder(),
    'form_id' => 1383,
    'user_id' => um_mumayizat-black(),
    'form_id' => 12003,
    ), $atts );

    extract( $atts );

    UM()->user()->target_id = $user_id;
    $value = "[ultimatemember form_id='{$form_id}']";

    if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
    return do_shortcode( $value );
    } else {
    return apply_shortcodes( $value );
    }
    }

and i putted both profile shortcode in profile tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment