Skip to:
Content
Pages
Categories
Search
Top
Bottom

Querying specific groups based on parameters


  • Aditya Singh
    Participant

    @stuffsone

    I needed to fetch the group avatar, group permalink and group description on the basis of “slug” or “id” (if by slug is not possible)….

    I tried using The Groups Loop / bp_has_groups(), since it shows that i can pass slug as a parameter…. but it doesn’t seem to work for me…. can someone tell me whats going wrong?

    a. the value of slug that I will be passing in bp_has_groups has to be a variable…. $slug_params for it to solve my purpose.
    b. I tried using bp_has_groups(‘slug = $slug_params’), (‘slug = “$slug_params”‘), even tried removing the $slug_params and replacing it with a fixed value put under quotes….none of it seems to work for me….

    What is it that I am missing out here?

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

  • r-a-y
    Keymaster

    @r-a-y

    Your bp_has_groups() line should look like this:
    bp_has_groups( 'slug=' . $slug_params )

    Your slug shouldn’t have quotes. Let’s say my group slug was “test-group”:
    $slug_params = 'test-group';


    Aditya Singh
    Participant

    @stuffsone

    Thanks for the reply @r-a-y
    I wasn’t expecting one so soon … :)
    I tried that…but it did not work….My understanding is that this text-box would not allow me to paste code….so Here is the link….
    http://pastie.org/private/8mymveqb0x5l04cvlm6aqa

    I am trying to just fetch the avatar, name of group based on slugs….as u can see, i echoed the $slug_params to see if that bit was working fine…it is… Help appreciated…


    Aditya Singh
    Participant

    @stuffsone

    and I have included the single quotes in the $params_slug variable….
    $slug_params = “‘” . $details_result . “‘”;
    I echoed the value after that


    r-a-y
    Keymaster

    @r-a-y

    Your pastie link doesn’t work.

    This is working for me:
    $myslug = 'my-test-group';
    if ( bp_has_groups('type=single-group&slug='.$myslug) )

    For some reason, you have to add the type as “single-group” as well.

    If you’re just trying to get the group avatar of one group… just use bp_group_avatar() (view the params in bp-groups-templatetags.php) or bp_core_fetch_avatar() (view params in bp-core-avatars.php).


    Aditya Singh
    Participant

    @stuffsone

    @r-a-y
    thanks mate…its just that I will be using the same thing…but for fetching different data on other areas of my site, so wanted to know bp_has_groups coz it will be needed eventually

    Pasting once more, making a final attempt at resolving this. Please have a look. Appreciate your patience with me.

    http://pastebin.com/tRRzw57E


    Aditya Singh
    Participant

    @stuffsone

    meanwhile, i am looking at the functions you mentioned….if this does not work, i will need them only… :)

    btw, just to bring it your attention: on codex.buddypress.org, the search form is not working…

    also on the page of bp_has_groups(), in the documentation it is written bp_has_site_groups()
    This might be right, but I could not find bp_has_site_groups() functions anywhere in the files in groups folder…so thought i will point these two issues out to you guys…hope its cool…

    first off – remove the single quotes around $slug_params = “‘” . $details_result . “‘”;

    second – no reason to pass in the slug param once you have the loop scope (everything is stored into a global context – just use the proper group template tags)


    Aditya Singh
    Participant

    @stuffsone

    oopsss…had forgotten to remove them from bp_group_permalink() and description_excerpt()
    actually when the earlier solution was not working, I tried that thinking may be there is the problem…
    anyway…have removed that…and have changed to $slug_params = $details_result;
    still no success… :(


    r-a-y
    Keymaster

    @r-a-y

    You should print out $details_result to make sure it is an accurate group slug.


    Aditya Singh
    Participant

    @stuffsone

    @nuprn1
    bp_has_activities and bp_has_groups -> both were working smoothly when I was using the predefined parameters…it is just not working when i am trying to pass this variable…


    Aditya Singh
    Participant

    @stuffsone

    @r-a-y
    when i am printing $slug_params, i am basically doing the same thing as printing $details_result
    isnt it???
    btw, i had printed that out as well…
    actually i am generating a list in this section (where I am stuck in fetching avatar and other details)….and every other bit is doing exactly what it should…
    again, thanks for being patient here…really appreciate it…


    Aditya Singh
    Participant

    @stuffsone

    resolved!

    Hi @r-a-y and @stuffsone, I am new to php, WP+BP. Could you please help me with exclude few Groups From the Loop. I would like to create a general group and donot want to display it in the Sidebar. Can we use the exclude parameters of bp_has_group in widget_logic? If yes can you help me with the syntax?
    Also I want to use the group functionality for Projects (as there is no plugin which fits the bill – I think I tried most of them ( Collabpress, BP GTM, Propel…)
    I am planning to create groups as projects but want them to be displayed under project tab (and not displayed under Group tab)
    do you have any other recommendation?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Querying specific groups based on parameters’ is closed to new replies.
Skip to toolbar