Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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