Any one available? Or should I post this in another section?
Try using bp_get_group_id()
.
If you can get the group id, then use groups_get_group_admins( $group_id )
to get the group admins.
Pull out the user ids of the group admins and use the ids to get the user data that you want.
NOTE: you should be asking LearnDash these questions.
By asking them here, you are asking volunteers to answer questions about a third-party premium plugin.
Therefore, you most likely won’t get much assistance here.
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?
>Am I on the right track?
This is wrong. bp_get_group_id(get_current_user_id());
Look up that function to see how it is used.
Ask LearnDash how to get the group id on the LearnDash screen that you want to use.
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 🙂