/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. Custom Yoast SEO Meta Data for Member’s Profile Page.

Custom Yoast SEO Meta Data for Member’s Profile Page.

By default, we do not have this option. You can use the following function code. Please see the steps below:

Note: Make sure to have a complete site backup before proceeding

1. Add a new profile field named “Bio.”  Follow this tutorial to learn more about profile fields. https://www.buddyboss.com/resources/docs/components/profiles/profile-fields/ 

2. After that, go to Appearance > Theme Editor.

3. Under “Select theme to edit,” choose “BuddyBoss Child/whatever theme is active,” then click Select.

4. Below Theme Files, select Theme Functions (functions.php).

5. Append the code just before the closing PHP tag “?>”:

//Create the members page's meta description. //It displays, like John - things entered in the bio field. add_filter( 'wpseo_metadesc', 'bb_custom_metadata_member_page' ); function bb_custom_metadata_member_page( $desc ) { if ( bp_is_blog_page() || bp_is_directory() ) { return $desc; } if ( bp_is_user() ) { $args = array( 'field' => 'Bio', ); $bio = bp_get_profile_field_data( $args ); if( empty( $bio ) ){ $bio = "Some default description, Please fill your bio in Profiles-Edit-Bio."; } $desc = sprintf( '%s - %s ', bp_get_displayed_user_fullname(), $bio ); } return $desc; }

6. Click “Update File” to save the changes.

You can use this function, “bp_get_profile_field_data,” to get any data from the member’s profile page. In the above example, I took the data from a custom field named “Bio.”

Note: Any modifications are considered as custom work already. Know more about our Support Policy here: https://www.buddyboss.com/support-policy/

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Support

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

"*" indicates required fields

Get Started

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

Name*