Skip to:

Does Buddypress disable autoembed and other the_content filter actions?

  • Garrett Hyder



    I originally noticed this issue with BuddyPress Groups Extras where their Group Pages loaded through BuddyPress groups aren’t picking up the autoembeds or shortcodes. If the Group Pages are loaded outside of the BuddyPress group they function as expected.
    References to the original issue;

    BP 2.2 Update Broke Auto-Embeds on BP Groups Extras Pages

    I came across this again as I’ve introduced a custom field ‘Group Content’ which adds content to the group overview page. Calling the_content() or apply_filters( ‘the_content’, get_the_content()) both fail to execute shortcodes and autoembeds (and probably any other the_content functions.

    Here’s the include file to introducing the Group Content meta to groups;

    Then from my custom front.php for Groups I introduce the group content field through the_content filter;

    <div class="group_content">
        $group_content = groups_get_groupmeta(bp_get_group_id(), 'bp_group_content_editor');
                echo apply_filters('the_content', $group_content);
        } else {
            echo "Please find any forums, documents or videos that you have access to listed in the sidebar.";

    Employing this technique I’ve found that no functions tied to the_content which would normally execute like autoembed and run_shortcodes no longer execute.

    Does BuddyPress suppress these functions on the_content filter?

    This seems to be the case not only in a custom field like this on the front.php but also any custom group pages introduced have the same issue.

    Thoughts/Insight appreciated. I tried diving into the BP code but got a bit overwhelmed. I think it might have to do with the buddypress template loader but can’t be sure.

    Anyway so this issue affects custom fields, custom pages and the plugin Buddypress Groups Extras which introduces Group Pages.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)

  • danbp


    For readers curious about the answer, autoembed does not run on meta items unless the dev runs it manually themselves ( @r-a-y ).

    More details on BuddyPress Slack.

    Garrett Hyder


    In the end utilizing BP_Media_Extractor with wp_oembed_get and do_shortcode I was able to get this functional;

    $group_content = groups_get_groupmeta(bp_get_group_id(), 'bp_group_content_editor');
    if(!empty($group_content)) {
    	$bp_extractor = new BP_Media_Extractor;
    	$media = $bp_extractor->extract( $group_content, BP_Media_Extractor::ALL );
    	if ( ! empty( $media['embeds'] ) ) {
    		foreach ( $media['embeds'] as $embed ) {
    			$cachekey = '_oembed_response_' . md5( $embed['url'] );
    			$oembed = groups_get_groupmeta( bp_get_group_id(), $cachekey );
    			if ( '' === $oembed ) {
    				$oembed = wp_oembed_get($embed['url']);
    				groups_update_groupmeta( bp_get_group_id(), $cachekey, $oembed );
    			if ( $oembed ) {
    				$group_content = str_replace($embed['url'], $oembed, $group_content);
    	if ( ! empty( $media['shortcodes'] ) ) {
    		foreach ( $media['shortcodes'] as $shortcode ) {
    			$cachekey = '_shortcode_response_' . md5( $shortcode['original'] );
    			$shortcode_content = groups_get_groupmeta( bp_get_group_id(), $cachekey );
    			if ( '' === $shortcode_content ) {
    				$shortcode_content = do_shortcode($shortcode['original']);
    				groups_update_groupmeta( bp_get_group_id(), $cachekey, $shortcode_content );
    			if ( $shortcode_content ) {
    				$group_content = str_replace($shortcode['original'], $shortcode_content, $group_content);
        echo wpautop($group_content);
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar