Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • Sergio Peña
    Participant

    @nexministry

    Here’s the code for anyone who wants to do the same:

    
    add_shortcode('course_mentor','group_course_mentor');
    
    function group_course_mentor($atts, $content = null){
      if(!is_user_logged_in())
        return;
      if(!bp_is_active('groups'))
        return;
      global $wpdb,$bp;
        $batches = groups_get_user_groups(get_current_user_id());
    $return = '';
      if(!empty($batches['groups'] )){
        foreach($batches['groups'] as $batch){
          $admins = groups_get_group_admins( $batch );
          foreach($admins as $admin){
            $return .=  '<a href="'.bp_core_get_user_domain($admin->user_id).'" title="'. bp_core_get_user_displayname( $admin->user_id, true ) .'">'.bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) .'</a>';
          }
        }
      }
      return  $return ;
    }
    

    Credit goes to Alex @ WPLMS for this 🙂


    Sergio Peña
    Participant

    @nexministry

    Thank you for your response.

    I did ask Learndash and they referred me to third party programmers.

    Since I am using buddypress groups, I thought it was appropriate to ask here as well. Apologies if I was mistaken!

    So would it be something like this:

    add_shortcode('course_mentor','nex_course_mentor');
    function nex_course_mentor($atts, $content = null){
      if(!is_user_logged_in())
        return;
      if(!bp_is_active('groups'))
        return;
    
      $nex_group_id  = bp_get_group_id(get_current_user_id());
    
      if(!empty($nex_group_id)){
        foreach($nex_group_id as $nex_group_id){
          $nex_admins = groups_get_group_admins( $nex_group_id );
          foreach($admins as $admin){
            ?>
            <a href="<?php echo bp_core_get_user_domain($admin->user_id) ?>"
            title="<?php echo bp_core_get_user_displayname( $admin->user_id, true ) ?>">
            <?php echo  bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?></a>';
      <?php
          }
        }
      }
    }

    I’m just copy/pasting and trying to connect a bunch of different answers together. As you can tell, I’m no coder.

    Since each group may have more than one group leader/mentor I had a loop in there. Hopefully that will get the ball rolling on what I’m trying to do.

    Am I on the right track?


    Sergio Peña
    Participant

    @nexministry

    Any one available? Or should I post this in another section?

Viewing 3 replies - 1 through 3 (of 3 total)
Skip to toolbar