Everything is for free!
Shop is closed.
Due to health issues support is very limited

file Redirecting based on usergroup

More
6 years 10 months ago #9629 by dunum2
Redirecting based on usergroup was created by dunum2
Hello there,

I'm trying to redirect if a user based on usergroups.
Here's my code :
if($user_id){
   //logged in
 $group = $usergroups[0];
   if($group==10){
    $redirect_menuitem_id = 177;

}else{
   //not logged in
   $message = Well it redirect correctly...';
   $message_type = 'info';
$redirect_menuitem_id = 146;
 //  $redirect_url = 'index.php?option=com_users&view=login';
}

I would like also to add a second case while the usergroup is different.
Thanks for your help !

Best regards

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago - 6 years 10 months ago #9630 by carsten888
Replied by carsten888 on topic Redirecting based on usergroup
congratulation with being the first to post in this forum
if($user_id){
   //logged in

   $group = $usergroups[0];
   if($group==10){
      //group 10
      $redirect_menuitem_id = 177;
   }else{
      //not group 10
      $redirect_menuitem_id = 177;
   }

}else{
   //not logged in

   $message = Well it redirect correctly...';
   $message_type = 'info';
   $redirect_menuitem_id = 146;
    //$redirect_url = 'index.php?option=com_users&view=login';

}

or if you want to also filter on another group
   $group = $usergroups[0];
   if($group==10){
      //group 10
      $redirect_menuitem_id = 177;
   }elseif($group==12){
      //group 12
      $redirect_menuitem_id = 112;
   }else{
      //not group 10 or 12
      $redirect_menuitem_id = 177;
   }
Last edit: 6 years 10 months ago by carsten888.

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #9631 by dunum2
Replied by dunum2 on topic Redirecting based on usergroup
Yeah first one :) !

Sorry, but still does not work...
Now into the url I got this :

my.domain.com/

Based on that code you gave, and I think it's clean, so no br anywhere...
if($user_id){
   //logged in
   $group = $usergroups[0];
   if($group==10){
      //group 10
      $redirect_menuitem_id = 126;
   }else{
      //not group 10
      $redirect_menuitem_id = 146;
   }
}else{
   //not logged in

   $message = Well it redirect correctly...';
   $message_type = 'info';
   $redirect_menuitem_id = 146;
}

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #9632 by carsten888
Replied by carsten888 on topic Redirecting based on usergroup
note the ' before Well it redirect.
if($user_id){
   //logged in
   $group = $usergroups[0];
   if($group==10){
      //group 10
      $redirect_menuitem_id = 126;
   }else{
      //not group 10
      $redirect_menuitem_id = 146;
   }
}else{
   //not logged in

   $message = 'Well it redirect correctly...';
   $message_type = 'info';
   $redirect_menuitem_id = 146;
}

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #9633 by dunum2
Replied by dunum2 on topic Redirecting based on usergroup
:)
Works fine, thanks !

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #9634 by carsten888
Replied by carsten888 on topic Redirecting based on usergroup
you're welcome

Please Log in or Create an account to join the conversation.

Time to create page: 0.148 seconds
Powered by Kunena Forum
 
spicy-sacerdotal