Skip to:
Content
Pages
Categories
Search
Top
Bottom

Issue with default groups widget


  • Anointed
    Participant

    @anointed

    One of my clients just pointed out something that I had not seen before, and I can’t find a solution.

    When you place the ‘groups widget’ on a page all is well, It works as expected.

    However:

    If I am viewing a profile page with the groups widget on the sidebar, it returns only the groups that the member belongs to.

    example:

    http://jerrygaffney.net/members/shawn/

    (no widgets on sidebar or footer because this user is not a member of any groups.. all other pages show the widget as expected)

    Now that is actually kind of cool, but it is causing me an issue.

    I am using the groups widget in my footer area, so that visitors have the ability to jump to a group very fast. When viewing the profile page of a member, the groups disappear if that member is not a member of a group.

    How do I go about turning off that behavior so it will always show the groups?

    better yet:

    How to duplicate the widget so that when used in a sidebar on profile pages it will list the groups the member being viewed is a member of, and yet still maintain my group listing widget in the footer that shows all?

    thanks….

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    Try feeding a blank ‘user_id’ argument into bp_has_groups in the widget to see if it fixes the problem.


    Anointed
    Participant

    @anointed

    Thank you, worked perfectly!

    In case anyone else runs into this issue, here are the changes

    bp-groups/bp-groups-widgets.php

    line 29:

    <?php if ( bp_has_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>

    change to:

    <?php if ( bp_has_groups( 'type=popular&user_id=""&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>

    One last question:

    I use widget_logic on my sidebars, what is the logic to say ‘is on members profile page’?

    Basically I duplicated the groups widget, one with the user logic, and one without. I can use my modified version in the footer, and the old one in the sidebar. That way I can also show what groups the member belongs to.

    I only want that widget to show up on buddypress profile pages. I just don’t see the logic statement anywhere.


    Boone Gorges
    Keymaster

    @boonebgorges

    I don’t know how WidgetLogic works, but you should be able to use something like:

    global $bp;
    if ( $bp->current_component == $bp->profile->slug ||
    ( $bp->current_component == $bp->activity->slug && $bp->current_action == 'just-me' ) )
    { /* Do your stuff here */ }


    Anointed
    Participant

    @anointed

    widget logic allows me to add a widget to the page and within each widget I can set variables like:

    is_page(), is_single(), is_author(), !is_home()

    So far I have not found one for bp. I have tried everything my brain can come up with like is_profile(), is_bp_profile(), etc…

    I’m sure hoping there are functions ‘whatever they’re called’ that work with buddpress specific areas. Otherwise I will end up having to do a load of coding I was hoping to avoid.


    r-a-y
    Keymaster

    @r-a-y

    Don’t trial and error functions!

    Look in bp-core-templatetags.php to find conditionals.

    It takes less than five minutes to do this.

    bp_is_my_profile()

    bp_is_directory()

    bp_is_profile_component()

    bp_is_activity_component()

    bp_is_blogs_component()

    etc.

    It’s all there.

    [EDIT]

    Just updated the conditional template tags page in the codex:

    https://codex.buddypress.org/developer-docs/conditional-template-tags/


    Anointed
    Participant

    @anointed

    Thank you so much!

    I tried bp_is_profile_component() as it looked like the most relevent. However it only shows the widget if on the users profile tab.

    I was hoping to find something like bp_is_user() where it would work on any page dealing with the members information, ‘activity, profile, messages, friends, etc’.. Is there an undocumented filter for this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Issue with default groups widget’ is closed to new replies.
Skip to toolbar