Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1219069

    Hi,

    I have installed BuddyPress to augment forum functionality on our site. On the automatically generated BuddyPress pages the default sidebar is displayed. I want to display a custom sidebar for these pages.

    I followed this https://kriesi.at/support/topic/buddypress-sidebar/ thread and this one, too https://kriesi.at/support/topic/buddypress-pages-custom-sidebar/. However, it doesn’t work.

    Including this the following code in line 47-48 of sidebar.php breaks all sidebars on all pages:

     $custom_sidebar = "Forum";
            if ( bp_is_activity() || bp_is_blogs() || bp_is_messages() || bp_is_friends() || bp_is_groups() ) { $custom_sidebar = "Forum"; }

    Including the following code doesn’t change anything and leaves the default sidebar displayed:

    $custom_sidebar = "Forum";
    if ( bp_current_component() ) { $custom_sidebar = "Forum"; }

    What is the best way to achieve displaying the sidebar named “Forum” on all BuddyPress pages? Also, I am looking for a solution that has the customization code in the child theme only.

    Find admin access to a staging site for you to have a look at the issue (private content).

    Thank you for the continued support and best regards,

    Peter

    #1221671

    Hey Peter,

    Sorry for the late reply!

    I reverted the changes you made in sidebar.php file and now I can see “forum” widget area is displayed on your forum pages.

    Could you please check your website and elaborate if you need further assistance? :)

    Best regards,
    Yigit

    #1221706

    Hi Yigit,

    thank you for the support.

    The” forum” sidebar has been displaying on the forum pages, specifically the bbpress pages, before already. I am looking to display the forum sidebar also on the BuddyPress pages.

    If you have a look at a BuddyPress page, it still shows the default sidebar. I think showing the custom “forum” sidebar on BuddyPress pages can only be achieved through a little bit of custom PHP. However, I was unable to achieve that by following the forum threads about the same issue which I posted above. In private content, find an example of a BuddyPress page.

    best regards,

    Peter

    #1221709

    Hi,

    Thanks for clarification!

    Please try using this plugin – https://wordpress.org/plugins/widget-logic/ and set “is_buddypress()” condition to widgets you would like to display on BuddyPress pages and “!is_buddypress()” condition to default widgets that you would not like to display on BuddyPress pages.

    Regards,
    Yigit

    #1221724

    Hi,

    thank you for the suggestion. setting “is_buddypress()” to respective widgets does not seem to work. now, also the bbpress pages have the default sidebar and BuddyPress pages still have the default sidebar too.

    Also I cannot set the default widgets to “!is_buddypress()” because the default widgets are not assigned anywhere under design>widgets.

    I would prefer a simple solution like proposed in this the below threads, instead of bloating up the site with plugins. I wonder why the proposed solution does not work anymore. Maybe because the solution is from 2015 and the enfold sidebar.php file changed over the year? 🤔

    https://kriesi.at/support/topic/buddypress-sidebar/
    https://kriesi.at/support/topic/buddypress-pages-custom-sidebar/

    #1221730

    UPDATE:

    I need to but the desired widgets for BuddyPress pages into “Displayed Everywhere” under design>widgets and then set “is_buddypress()”, while leaving everything else untouched.

    Now, it seems to have the “forum” sidebar replicated on BuddyPress pages. (you may want to check yourself)

    I still would prefer to set
    if ( bp_current_component() ) { $custom_sidebar = "special"; }

    in sidebar.php, or better in child theme function.php, but it doesn’t seem to work.

    #1223808

    Hi,

    Thank you for that info. Have you tried using the avf_custom_sidebar filter to change the current sidebar on a specific archive page?

    add_filter('avf_custom_sidebar','avf_custom_sidebar_mod');
    function avf_custom_sidebar_mod($sidebar) {
    	if ( CONDITIONS HERE ) {
    		$sidebar = "special";
    	}
    	return $sidebar; 
    }

    Replace the placeholder with the actual conditions.

    This might help: https://codex.buddypress.org/developer/template-tag-reference/

    Best regards,
    Ismael

    #1228301

    Hi,

    unfortuantely, your last code suggestion does not work either.

    best regards, peter

    #1229356

    Hi,

    Did you adjust the condition? What are the conditional tags that you’ve tried in the if statement?

    if ( CONDITIONS HERE ) {
    

    Best regards,
    Ismael

    #1229447

    Hi Ismael,

    this is the code I included in child theme functions.php

    //custom forum sidebar on buddypress pages
    add_filter('avf_custom_sidebar','avf_custom_sidebar_mod');
    function avf_custom_sidebar_mod($sidebar) {
    	if ( bp_current_component ) {
    		$sidebar = "Forum";
    	}
    	return $sidebar; 
    }

    The sidebar I am trying to place on buddypress pages is called “Forum”. Using the code above also leads to that sidebar being displayed on the Blog pages. However on the blog there should be the “Blog” sidebar.

    best regards, peter

    #1229827

    Hi,

    Thank you for the update. I believe this line:

    if ( bp_current_component ) {
    

    .. should be:

    if ( bp_current_component() ) {
    

    .., and if you want to exclude the blog pages or to prevent the “Forum” sidebar from displaying on it, try this condition:

    if ( bp_current_component() && ( !is_home() && !is_page(ID OF THE PAGE HERE)) ) {
    

    Replace the placeholder in the is_page function with the actual ID of the blog page. The condition is_home should be enough, but it’s not going to work if you didn’t set the blog as the main blog or posts page in the Settings > Reading or the the Enfold > Theme Options panel.

    Best regards,
    Ismael

    #1229989

    Hi Ismael,

    thank you for the reply. I think the missing brackets were the problem. The following code does what I want to achieve, which is show the custom sidebar on buddypress pages.

    //custom forum sidebar on buddypress pages
    add_filter('avf_custom_sidebar','avf_custom_sidebar_mod');
    function avf_custom_sidebar_mod($sidebar) {
    	if ( bp_current_component() ) {
    		$sidebar = "Forum";
    	}
    	return $sidebar; 
    }

    There does not seem to be the need for more conditions, like you outnlined above, because the blog sidebar displays on the blog, as intended.

    #1230599

    Hi,

    Great! Glad to know that it’s working properly now. Please feel free to open another thread if you need anything else.

    Have a nice day.

    Best regards,
    Ismael

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.