Last active
February 10, 2019 11:07
-
-
Save champsupertramp/ad3967056c7d021b21f76400326188ef to your computer and use it in GitHub Desktop.
Example of Ultimate Member Cover photo in Open Graph Image meta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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