Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/ad3967056c7d021b21f76400326188ef to your computer and use it in GitHub Desktop.
Save champsupertramp/ad3967056c7d021b21f76400326188ef to your computer and use it in GitHub Desktop.
Example of Ultimate Member Cover photo in Open Graph Image meta
add_action("init","um_custom_init");
function um_custom_init(){
remove_action('wp_head', 'um_profile_dynamic_meta_desc', 9999999);
}
add_action('wp_head', 'um_custom_profile_dynamic_meta_desc', 9999999);
function um_custom_profile_dynamic_meta_desc() {
global $ultimatemember;
if ( um_is_core_page('user') && um_get_requested_user() ) {
um_fetch_user( um_get_requested_user() );
$content = um_convert_tags( um_get_option('profile_desc') );
$user_id = um_user('ID');
$url = um_user_profile_url();
if ( um_profile('cover_photo') ) {
$cover_uri = um_get_cover_uri( um_profile('cover_photo'), null );
} else if( um_profile('synced_cover_photo') ) {
$cover_uri = um_profile('synced_cover_photo');
}else{
$cover_uri = um_get_default_cover_uri();
}
um_reset_user(); ?>
<meta name="description" content="<?php echo $content; ?>">
<meta property="og:title" content="<?php echo um_get_display_name( $user_id ); ?>" />
<meta property="og:type" content="article" />
<meta property="og:image" content="<?php echo $cover_uri; ?>" />
<meta property="og:url" content="<?php echo $url; ?>" />
<meta property="og:description" content="<?php echo $content; ?>" />
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment