Hook in a sidebar widget and add some markup

I don’t think it can be done. I’m sorry, but this widget has no hooks in there. You can only use bp_has_members hook, but you shouldn’t use it to echo anything, because it’s used in many other places, so you may break some things doing it this way.

The only way I can see to achieve this (and it’s not perfect), is to write your own widget based on this BP widget. To do that you should:

  1. Find the original widget’s source code. (It’s in bp-core/bp-core-widgets.php file)
  2. Copy it’s code and place it in your themes function.php
  3. Rename it properly (take care of class name, and so on).
  4. Register your new widget with:

    add_action(‘widgets_init’, create_function(”, ‘return register_widget(“”);’) );

You can also try to inherit this new widget class from original BP widget class (you won’t need to copy entire source code then).