Skip to:
Content
Pages
Categories
Search
Top
Bottom

profile page sidebar assignment


  • Steve
    Participant

    @aksteve

    It appears that buddypress uses my default sideabar on the profile page. I have searched for a plugin that will help me take control of this. (who wants a list of blog posts on their profile page… it should be group and member info).

    I found a plugin that sorta works. The problem is there doesn’t appear to be an actual “profile page” to assign the sidebar to. There is a member page, an activity page and a group page, but no profile page.

    Can anyone help? I can’t be the only one who has this issue.

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

  • Venutius
    Moderator

    @venutius

    Yes, you are looking for Content Aware Sidebars, this plugin allows you to create sidebars for each individual profile page view if you wanted to, it’s a little complex at first. I ended up just putting every possible profile page view into the one sidebar and choosing to replace the default sidebar with that.


    Steve
    Participant

    @aksteve

    I think this might work. But I do not see the buddypress “profile” page in there. I just don’t see a “profile” page anywhere.

    Would I have to buy the premium plugin and use a custom URL. That means it would have to override the themes default sidebar. Seems risky for $50?

    Thanks for the link. I guess I will contact them to be assured this will work. I am tired of trying plugin and plugin after plugin…


    Venutius
    Moderator

    @venutius

    It’s the “BuddyPress Members” option, down the bottom of the list. To my knowledge this is the only plugin that does this so far, I’m hopeful that woosliders can incorporate BuddyPress at some stage.


    Steve
    Participant

    @aksteve

    Holy crap – it worked. THanks so much.

    Man, I am so jaded these days… sorry about my negative attitude.

    Finally, something that worked!


    Venutius
    Moderator

    @venutius

    Yep I’ve been playing with it myself tonight, I found that you can also personalise those BuddyPress pages that are static and have a WordPress page such as Members or Groups.

    It’s a shame it only does half the job and I’m not sure the Pro version does all of the other half, it does Groups, which I think is a big thing – to have each group sidebar as unique as the group is a nice idea. But there are other pages I’m not sure even the pro version covers.

    I might be wrong though so I’m planning on testing it.


    danbp
    Moderator

    @danbp

    Hi guys,

    you don’t need a plugin to get a contextual sidebar. You can do that with a few conditionnals and a function. Let’s take 2016 as example.

    Copy sidebar.php file of your theme to child-theme.
    Add an action hook to the template. Ie. xtra_sidebar
    Almost done !

    In Twenty Sixteen, it looks like this:

    <aside id="secondary" class="sidebar widget-area" role="complementary">
    
    	<?php do_action( 'xtra_sidebar' ); ?>
    	<?php dynamic_sidebar( 'sidebar-1' ); ?>
    
    </aside>

    Into bp-custom.php or child theme functions.php you add following function(s)

    If you want different custom sidebar content for different groups:

    function xtra_group_sidebar() {
       if ( bp_is_active( 'groups' ) ) {
    
          // conditionnal for group name (slug format)
          if ( bp_is_groups_component() && 'kill-bill' == bp_current_item() ):
    
    	 // your content
    	 echo '<section id="categories-2222" class="widget widget_categories">';
    	 echo '<h2 class="widget-title">what time is it Bill ? </h2>';
    	 $my_date = date('H:i'); echo $my_date; 
             echo '</section>';
          endif;
    		
          if ( bp_is_groups_component() && 'terminator' == bp_current_item() ):
    	 echo '<h3 style="color:red">WHO KNOWS ?</h3>';
          endif;
    		
          if ( bp_is_groups_component() && 'harry-poter' == bp_current_item() ):
             echo 'Hou ouh...';
          endif;
       }
    }
    add_action( 'xtra_sidebar', 'xtra_group_sidebar' );

    If you want a custom sidebar for profiles only, you use:

    function xtra_profile_sidebar() {
    
    	if ( bp_is_active('xprofile' ) && bp_is_user() ) {
    		?><section id="categories-1111" class="widget widget_categories">
    		<h2 class="widget-title">My profile sidebar</h2>
    		My sidebar content</section>
    <?php
    	}
    
    }
    add_action( 'xtra_sidebar', 'xtra_profile_sidebar' );
    function xtra_directory_sidebar() {
    
       if ( bp_is_active('xprofile' ) && bp_is_user() ) { 
    ?>
          <section id="categories-1111" class="widget widget_categories">
          <h2 class="widget-title">My directory sidebar</h2>
          My directory content</section>
    <?php
    	}
    }
    add_action( 'xtra_sidebar', 'xtra_directory_sidebar' );

    You can of course use the same technique for all other BP components.
    For profiles, you can even add a user_id check so you can personalize the sidebar for a given user.
    Or create a sidebar for visitors and another one for logged_in members… Sky is the limit ! ๐Ÿ˜‰

    Note that the div and css names are theme dependant. The example use those of 2016 but you have to adjust that to fit your theme.

    Note also that most sidebars use listed content (ul/li). Try to respect that or you might break your theme. Check how it’s done and use the same. If you find ID numbers, use a very high number ! I use 1111, because i will never have 1111 widgets in my sidebar ! ๐Ÿ˜‰

    Another way to do that would be to add conditionnals into the sidebar template. For example:

    if ( !this_component() ) {
       show the original sidebar
    } else {
       show my xtra sidebar
    }

    Hope it helps and happy templating ! ๐Ÿ™‚


    Venutius
    Moderator

    @venutius

    This looks very interesting, I’ll have a play this weekend


    Venutius
    Moderator

    @venutius

    @danbp
    This is right over my head but I’ll try and run with it. Where do I put the action hook? functions.php?


    danbp
    Moderator

    @danbp

    i use them in bp-custom, but i suppose it will work also in child-thme’s functions.php

    That said i mentionned this in my previous post. ๐Ÿ™‚


    superbohne
    Participant

    @superbohne

    Hello,

    this looks very interesting to me!

    It is possible to include a sidebar, generated in wp backend, by this way?

    Ie, i generated a sidebar named “side_members_single”… how to call that one? iยดm a bit confused ๐Ÿ™‚

    Mh. Could you help?

    Thanks for ur efforts & and best regards from Germany.


    Prashant Singh
    Participant

    @prashantvatsh

    https://codex.wordpress.org/Function_Reference/dynamic_sidebar

    We can use this function to call the sidebar.

    Thanks


    superbohne
    Participant

    @superbohne

    thanks a lot for your help!


    Prashant Singh
    Participant

    @prashantvatsh

    Welcome ๐Ÿ™‚

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