• Resolved fidoboy

    (@fidoboy)


    Hi,

    Right now I’m using another plugin that generates automatically all OpenGraph metas for all pages and posts in my site. So when looking at page source for users, I can see duplicated metas being generated by Ultimate Member plugin.

    So my question is really simple: How can I disable the function that generates the og metas in Ultimate Member? There is any hack or trick to remove them using functions.php in my theme’s folder?

    Thanks in advance,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @fidoboy

    If you just want to remove meta tags generated by Ultimate member, you can try following code snippets:

    remove_action( 'wp_head', 'um_profile_dynamic_meta_desc', 20 );

    Thread Starter fidoboy

    (@fidoboy)

    Thanks a lot. I’ll try it by adding into my functions.php and I’ll return here with the results,

    Kind regards,

    Thread Starter fidoboy

    (@fidoboy)

    Hi again. It works fine, but problem is that it removes ALL metatags, also the page description, not only the OpenGraph metas for social sharing that it’s what I want.

    There is any option to disable ONLY social sharing metas? Any hook perhaps where I can remove only certaing metas or add it with my own code? I do not want to disallow the user profile description.

    Regards,

    @fidoboy

    You can try this code snippet where the meta property="og: lines are removed and you can change all the remaining lines as you like:

    remove_action( 'wp_head', 'um_profile_dynamic_meta_desc', 20 );
    add_action( 'wp_head', 'um_profile_dynamic_meta_desc_custom', 20 );
    
    /**
     * The profile page SEO tags
     *
     * @see https://ogp.me/ - The Open Graph protocol
     * @see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary - The Twitter Summary card
     * @see https://schema.org/Person - The schema.org Person schema
     */
    function um_profile_dynamic_meta_desc_custom() {
    	if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
    
    		$user_id = um_get_requested_user();
    
    		if ( $user_id !== um_user('ID') ) {
    			um_fetch_user( $user_id );
    		}
    
    		/**
    		 * Settings by the priority:
    		 *  "Search engine visibility" in [wp-admin > Settings > Reading]
    		 *  "Profile Privacy" in [Account > Privacy]
    		 *  "Avoid indexing my profile by search engines in [Account > Privacy]
    		 *  "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
    		 *  "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
    		 */
    		if ( UM()->user()->is_profile_noindex( $user_id ) ) {
    			echo '<meta name="robots" content="noindex, nofollow" />';
    			return;
    		}
    
    		$locale = get_user_locale( $user_id );
    		$site_name = get_bloginfo( 'name' );
    
    		$twitter = (string) um_user( 'twitter' );
    		if ( ! empty( $twitter ) ) {
    			$twitter = trim( str_replace( 'https://twitter.com/', '', $twitter ), "/ \n\r\t\v\0" );
    		}
    
    		$title = trim( um_user( 'display_name' ) );
    		$description = um_convert_tags( UM()->options()->get( 'profile_desc' ) );
    		$url = um_user_profile_url( $user_id );
    
    		$size = 190;
    		$sizes = UM()->options()->get( 'photo_thumb_sizes' );
    		if ( is_array( $sizes ) ) {
    			$size = um_closest_num( $sizes, $size );
    		}
    		$image = um_get_user_avatar_url( $user_id, $size );
    
    		$person = array(
    			"@context"      => "https://schema.org",
    			"@type"         => "Person",
    			"name"          => esc_attr( $title ),
    			"description"   => esc_attr( stripslashes( $description ) ),
    			"image"         => esc_url( $image ),
    			"url"           => esc_url( $url ),
    		);
    
    		um_reset_user();
    		?>
    		<!-- START - Ultimate Member profile SEO meta tags -->
    
    		<link rel="image_src" href="<?php echo esc_url( $image ); ?>"/>
    
    		<meta name="description" content="<?php echo esc_attr( $description ); ?>"/>
    
    		<meta name="twitter:card" content="summary"/>
    		<?php if ( $twitter ) { ?>
    			<meta name="twitter:site" content="@<?php echo esc_attr( $twitter ); ?>"/>
    		<?php } ?>
    		<meta name="twitter:title" content="<?php echo esc_attr( $title ); ?>"/>
    		<meta name="twitter:description" content="<?php echo esc_attr( $description ); ?>"/>
    		<meta name="twitter:image" content="<?php echo esc_url( $image ); ?>"/>
    		<meta name="twitter:image:alt" content="<?php esc_attr_e( 'Profile photo', 'ultimate-member' ); ?>"/>
    		<meta name="twitter:url" content="<?php echo esc_url( $url ); ?>"/>
    
    		<script type="application/ld+json"><?php echo json_encode( $person ); ?></script>
    
    		<!-- END - Ultimate Member profile SEO meta tags -->
    		<?php
    	}
    }
    • This reply was modified 2 years, 8 months ago by missveronica.
    Thread Starter fidoboy

    (@fidoboy)

    That’s what I was looking for. Thanks a lot again. That way I can just remove all Twitter related lines, and my HTML code is generated now flawlessly and there is no duplicated metas.

    Problem solved. Thanks!!!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know how it resolves the issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable Open Graph metatags in users pages’ is closed to new replies.