Skip to:

Need Help Cloning/Modifying the ”Groups” Widget

  • Anyone up for helping me a bit via pastebin? I want to make a clone of the default BP groups widget that just displays the latest active group avatars (with the group name and member count in the tooltip on hover). I plan on widgetizing a spot directly to the right of the user avatar on member-header.php and using my new widget there to display the avatars (about 25px square in a 3×5 grid) of the groups the current member belongs to.

    Is there any way someone who knows about widget creation could look at this and proof it for me? Also, would this go into bp-custom.php or my theme functions.php?

    I did remove (hopefully completely and without causing errors) the newest/active/popular filter. I just want the top X (whatever I set in the widget config on the widgets page) latest active groups to be displayed. I *think* I got that part right in the pastebinned code. Also, is there any way to return something like “USERNAME is a member of X groups” (X = n, of course)?

    Thanks in advance for any help you can offer with this!

    ETA: OK, nevermind, I think I’ve got the widget working without error! I just need to widgetize the area on member-header.php that I wanted to put these in :)

    I’d still like to know if there’s a way to pull in the number to display a statement about how many groups the current member belongs to, and I also have a new question…would it be possible to exclude a few groups from displaying here? I’m going to try adding “&exclude=” with the ID numbers, but if I’m on the wrong track here, please let me know!

Viewing 8 replies - 1 through 8 (of 8 total)
  • OK…no exclude parameter, I’m guessing, since I can’t find an ID# for a group?

    I have the group tags plugin installed and was wondering if I could maybe exclude certain groups via tag? I have this, but I’m just guessing at the php syntax and whether I have the right function from the group tags plugin:

    OK, that is obviously NOT correct. Help?

    Loving talking to myself here, lol!

    OK, so I moved on from the exclude thing for a moment and decided to go ahead and place my widgetized area into member-header.php. I totally thought I had this part down, but apparently not :/

    Anyone know why widgetizing an area like I have in this code would create an “unexpected $end” error for the last line of member-header.php (which happens to be “do_action( ‘template_notices’ )”)?

    And yes, I did register the widget and the sidebar area in my functions.php. I’m able to successfully drag my new widget into the sidebar of my site and it works flawlessly there.

    Very often with errors in either scripting or markup the reported point of error is not necessarily where the actual problem starts from it’s just where the validation finally fails to be able to parse the logic.

    You are saying ‘IF’ something then do something and we are waiting for that to be finished, however you are only showing a snippet of code out of context which does mean one can only base things on what is shown.

    looks like you have lifted the code that is used for the ‘if no widgets run the add widgets error markup’ that is really used more for distributed themes, the ! ‘not’ operator is useful for saying if these functions don’t exist and can’t be called then fallback to this following markup/script. Your code as written needs endif;

    You can write the dynamic sidebar call in a more straightforward manner?

    if ( function_exists(‘dynamic_sidebar’) )
    dynamic_sidebar(“Profile Groups Area”) ;

    The WP codex page gives more info:

    @hnla: thanks for the reply :)

    I only have a few minutes before I need to leave for the afternoon, but if there’s any possible way you could have a look at these, I’d really appreciate it! I’m at my mind-scrambled point with looking at the code myself.

    Here’s my member-header.php, including the newly widgetized area, and the functions.php in question. Getting rid of the div that contains the new sidebar area next to the member avatar solves the issue, so I’m thinking that the problem lies in my functions.php where the widget is actually created.


    Your pate bin code still shows the same sidebar call does my version not work? or perhaps this version so that you don’t needlessly render markup if no widgets in area

    <?php if(function_exists(‘dynamic_sidebar’) ) : ?>
    <?php dynamic_sidebar(“Profile Groups Area”) ; ?>

    Hmm escaping code has mucked up rendering and edit ability!!

    @hnla: eek! And no, I’m sorry, I hadn’t tried that yet. Off to do so now. Thanks for replying again!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Need Help Cloning/Modifying the ”Groups” Widget’ is closed to new replies.
Skip to toolbar