1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Add Custom Yoast SEO Meta Data for a Member’s Profile Page

How to Add Custom Yoast SEO Meta Data for a Member’s Profile Page

Introduction

BuddyBoss does not provide a built-in option to customize Yoast SEO meta descriptions for individual member profile pages. However, you can use a small custom function to dynamically generate meta descriptions from a member’s profile fields (e.g., Bio field). This guide explains how to add custom Yoast SEO meta data for a member’s profile page.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. Add a new profile field named Bio in your BuddyBoss member profiles.
    Learn how here: Profile Fields Documentation
  2. Go to Appearance > Theme Editor in your WordPress admin dashboard.
  3. Under Select theme to edit, choose your active theme (preferably BuddyBoss Child Theme), then click Select.
  4. From the Theme Files list, open Theme Functions (functions.php).
  5. Add the following code just before the closing PHP tag (?>):
<?php

// Create the members page's meta description using the Bio profile field

add_filter( 'wpseo_metadesc', 'bb_custom_metadata_member_page' );

function bb_custom_metadata_member_page( $desc ) {

    // Exclude blog pages and directories

    if ( bp_is_blog_page() || bp_is_directory() ) {

        return $desc;

    }

    // Only modify for user profile pages

    if ( bp_is_user() ) {

        $args = array(

            'field' => 'Bio', // Name of the profile field

        );

        $bio = bp_get_profile_field_data( $args );

        if ( empty( $bio ) ) {

            $bio = "Some default description. Please fill your Bio in Profiles → Edit → Bio.";

        }

        // Format meta description: "John Doe - Bio text"

        $desc = sprintf( '%s - %s', bp_get_displayed_user_fullname(), $bio );

    }

    return $desc;

}

?>

Note: You can use the bp_get_profile_field_data function to pull data from any profile field. In this example, we used the Bio field.

  1. Click Update File to save the changes.

Note: Modifications are typically considered custom work, but we are making an exception in this case. Please review the BuddyBoss Support Policy.

Troubleshooting and FAQs

Q: The meta description is not updating on member pages.
A: Ensure the code is added to your child theme’s functions.php file. Also, clear any caching or SEO plugin caches.

Q: Can I use other profile fields instead of Bio?
A: Yes. Replace ‘Bio’ in the $args array with the name of any custom profile field.

Q: Will this affect other pages?
A: No. This only modifies meta descriptions on individual member profile pages.

Q: Can I revert this change easily?
A: Yes. Remove or comment out the code from functions.php and save the file.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.