Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditional Tags for specific group

  • I am using widget-logic and would like to show a widget only on one specific group.
    This is what I tried:
    bp_is_group(’69′) (with the group id)
    bp_is_group(‘group-slug’) (with the groups slug)

    both doesn’t seem to wrk, for the widget shows in all of the groups (although only in the groups)

    Can somebody tell me, if this is possible and if so, how?

    THANKS!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Avatar of stwc
    stwc
    Participant

    @stwc

    I just tried adding `bp_is_group_forum() && bp_group_is_visible()` and it worked fine (showing the widget only on Group forums pages), so clearly something might be possible. How exactly to show it for a specific group, though… I’ll keep trying.

    Avatar of stwc
    stwc
    Participant

    @stwc

    Hmm. Tried a whole bunch of variations. No luck.

    Maybe (just off the top of my head) a new function in functions.php that returns the current group name or id, then check the value of that function in the widget logic parameter field?

    Thanks for trying! So I guess it seems that bp_is_group() doesn’t have additional information (is that correct, @apeatling?)…
    Could you give me an example for the code that needs to go in the functions.php (of the theme, right?)? (sorry, I am no programmer…)

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    This works for a single group view:

    if(bp_is_groups_component() && ‘MyGroupName’ == bp_current_item()):

    @hnla – sounds good! As I said, I am no programmer…
    Can you tell me, for this is code for a template-file, what part I would have to put in the widget-logic widget (for with this code above it doesn’t seem to work there…)?
    And the MyGroupName: is that the slug, or the actual name or the ID?
    Thanks alot for your help!

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It’s the actual group name.

    Not really sure how you’re doing things, but if you were creating a function and using Do Action hooks to return the function to where needed could you not simply use the conditional to wrap the code / widget code in so the function returns but it’s code is only parsed if meeting the conditionals requirements – not sure that would work and there will be doubtless a much better method that one of the more experienced hands could suggest, also that conditional would I think only work on an actual group page so may not suit what you are trying to do.

    Thanks again.

    1. As I said, I cannot answer the “question” if wrapping up the functions-code would work – no idea… :-(
    2. It should work only on ONE page (there one special widget should be shown). With the widget-logic-plugin I can limit a widget with conditionals like bp_is_group().

    My question is, what piece of code do I have to put in there?
    And: The actual group name? Really? Like: O2 PRAY!Netwörk?

    Sorry, maybe it’ is hard to explain this to me…

    Ok, I think I found out now. Thanks @hnla for pointing me in the right direction.
    I just copied your code an the ” were wrong – so the code didn’t work

    Here is what works now with the widget-logic-plugin in my install:

    bp_is_group() && ‘myGroupSlug’ == bp_current_item()

    It just works :-) No idea if it should ;-) – but I am happy for now!

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Guess the two are much the same thing really at least the ‘myGroupslug’ == bp_current_item is as for the difference between bp_is_group() and bp_is_groups_component() is in this scenario I’m not too sure, I think that probably bp_is_group() would work equally well in my situation.

    I was more interested in seeing just how you were dealing with the widget as such, I tend to dislike widgets and although used where I need to affect something would tend to write it as a function. taking the important working parts and setting them as a function which I could then gain a finer degree of control over in terms of how or when it appears.

    Avatar of Scotm
    Scotm
    Participant

    @scotm

    I’ve been trying to figure this out as well.

    Happy to say that: bp_is_groups_component() && ‘myGroupSlug’ == bp_current_item() works on my install with WP 3.0 beta.

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

You must be logged in to reply to this topic.