Skip to:
Content
Pages
Categories
Search
Top
Bottom

Meta Title of the profile in Buddypress


  • mihaylovra
    Participant

    @mihaylovra

    Hello!

    I would like to set up the Meta Title of the profile in Buddypress. For example, to be in the Meta Title: User name, city, country.

    How to do it? Help please.

    I have a code that adds a description to a profile and it works. But I did not find how to replace the title.

    /**
     * Filters wpseo meta desc.
     *
     * @param string $desc description.
     *
     * @return string
     */
    function bpdev_bp_items_metadesc( $desc ) {
    	// if it is not buddypress page or buddypress directory pages let the plugin do its work.
    	if ( bp_is_blog_page() || bp_is_directory() ) {
    		return $desc;
    	}
    	// we do not cover directory as directory meta can be customized from pages->Edit screen
    	// now, let us check if we are on members page.
    	if ( bp_is_user() ) {
    
    		// what should me the description, I am going to put it like Profile & Recent activities of [user_dsplay_name] on the site [sitename]
    		// if you are creative, you can use some xprofile field and xprofile_get_field_data to make it better.
    		$desc = sprintf( ' Профиль %s и его активность на сайте знакомств %s ', bp_get_displayed_user_fullname(), get_bloginfo( 'name' ) );
    	} elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
    		// for single group
    		// let us use group description.
    		$desc = bp_get_group_description( groups_get_current_group() );
    
    	}
    	// do it for other components
    	// ok, so you can go and do the same for all the other pages
    	// finally return the description.
    	return $desc;
    
    }
    
    add_filter( 'wpseo_metadesc', 'bpdev_bp_items_metadesc' );
Viewing 1 replies (of 1 total)

  • mihaylovra
    Participant

    @mihaylovra

    It turned out to make a profile title as well:

    /**
     * Filters wpseo meta title.
     *
     * @param string $title title.
     *
     * @return string
     */
    function bpdev_bp_items_title( $title ) {
    	if ( bp_is_blog_page() || bp_is_directory() ) {
    		return $title;
    	}
    	if ( bp_is_user() ) {
    		$title = sprintf( ' %s @%s looking for dating in %s ', bp_get_displayed_user_fullname(), bp_get_displayed_user_username(), bp_get_member_profile_data('field=City') );
    	} 
    	return $title;
    }
    
    add_filter( 'wpseo_title', 'bpdev_bp_items_title' );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar