Adding Custom Content to Default BuddyPress Pages?

I feel like as much time as I have spent in BuddyPress I should know this, but I don’t. I assume there is a way, preferably somewhat easy, to add content to the default pages in BuddyPress. For example, the forums page has a built in search feature there, and I would like to replace it, but there is also some other text on other default pages I would like to add. Is that possible?

Thanks, David

  • Vinod Dalvi
    • WP Unicorn

    Hi David,

    I hope you are well today and thank you for your question.

    Yes it’s possible just tell me a bit more in detail on which pages what changes you want to make so that i can help you to achieve it?

    Also you are talking about forums page so are you using bbPress plugin?

    Please advise.

    Kind Regards,

    Vinod Dalvi

  • Ash
    • Code Norris

    Hello @David

    I hope you are well today.

    This depends on the theme you are using. Does it have any custom buddypress template?

    I may try to add text using some jquery. Where do you want to add text? At the top? Bottom? Please mention :slight_smile:

    Also, what text or code you want to apply in there? Please explain in details.

    Cheers

    Ash

  • David
    • The Incredible Code Injector

    I am using the social theme for WPMU. So I haven’t finalized it yet, but for example I would like to add some text ( a couple sentences) and ideally the shortcode for AJAX search on the top of probably the forums and therapists page. So for example this shortcode would be one possibility – [wpdreams_ajaxsearchpro id=4], but in general I would love to be able to add text regardless to the top, but nothing more than a 1-3 sentences. Thanks!

  • Ash
    • Code Norris

    Hello @David

    Would you please try the following code in theme’s footer.php after wp_footer() just for testing if that works?

    <script type="text/javascript">
    jQuery(function($) {
    var html = '<div class="custom_html"><p>Some text and content</p><?php echo do_shortcode( '[wpdreams_ajaxsearchpro id=4]' ); ?></div>';
    $('#buddypress').prepend(html);
    });
    </script>

    Please let me know how it goes.

    Cheers

    Ash

  • Ash
    • Code Norris

    Hello @David

    assuming you wanted it directly after the () and before the ;

    Sorry, I didn’t explain well.

    After wp_footer(); you will see a php end tag, like ?>. Put the code after that:

    ?>
    <script type="text/javascript">
    jQuery(function($) {
    var html = '<div class="custom_html"><p>Some text and content</p><?php echo do_shortcode( '[wpdreams_ajaxsearchpro id=4]' ); ?></div>';
    $('#buddypress').prepend(html);
    });
    </script>

    Let me know if it works.

    Cheers

    Ash

  • David
    • The Incredible Code Injector

    Thanks Ash – see attached. I did grant you access so feel free to take a look. Given this is just the footer that is fine, but if you want access to staging I can grant that as well. Thanks, David

    [attachments are only viewable by logged-in members]

  • Ash
    • Code Norris

    Yes, I can see the issue. Your shortcode is generating html, that’s why is creates a js error.

    Would you please try the following code:

    add_action( 'bp_before_member_header', 'my_custom_code' );
    add_action( 'bp_before_group_header', 'my_custom_code' );
    function my_custom_code() {
    echo do_shortcode( "[wpdreams_ajaxsearchpro id=4]" );
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash