Hi,
Can you tell me if there is a way to redirect a batch moderator directly to the batch statistics page upon login. We are trying to use Batches plugin for a corporate training site and would like to separate the Batch moderator, who will be administrating the batch, from any other course functionality (like taking courses of his own). We will have one user moderating only one group.
This is not possible because a user can create many batches they want and we cannot find which batch statistics he should be redirected to.
I should have been clearer in my previous message. We will be disabling group creation by normal users and assign a user as moderator ourselves. So we will in fact make sure that a user has only one group whether he is a moderator or just a student. Hence i think it should not be a problem as there will be only one group a user is member of.
I would like to know how to detect if a user is a group moderator at login and use the method given by you at the below link and redirect the moderator to his batch stats page.
https://wplms.io/support/knowledge-base/login-redirect-to-a-custom-page/
So kindly share code to detect
1) if the user from '$user' variable in the function is a batch member and
2) to check if he is a moderator of that batch
assuming that the user is part of only one group
Try using this code :
----
add_filter('login_redirect',function($url){
if(!is_user_logged_in())
return $url;
$user_id = get_current_user_id();
global $wpdb,$bp;
$group_id = $wpdb->get_var("SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = $user_id AND is_mod=1");
if(empty($group_id) || !defined('WPLMS_BATCH_STATISITCS_SLUG')){
return $url;
}
$group = groups_get_group($group_id);
$url = untrailingslashit( bp_get_group_permalink( $group ) ) . '/'.WPLMS_BATCH_STATISITCS_SLUG.'/';
return $url;
},101,1);
----
LEt me know if you need any further help with this customisation.
p.s : Customisation requests are not part of theme support.