• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: set the Return URL based on usergroup

set the Return URL based on usergroup 10 years 8 months ago #28596

  • djseleco
  • djseleco's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Thank you received: 10
Hello i need to set the 'Return URL' based on usergroup of user logged.
Example: if the form will be submitted by 'Registered' user the Return URL must be www.mydomain.com/page1
if submitted by Admin must be www.mydomain.com/page2
It's possibile?
Someone can help me?
Thanks in advance
Last Edit: 10 years 8 months ago by djseleco.
The administrator has disabled public write access.

set the Return URL based on usergroup 10 years 8 months ago #28602

  • djseleco
  • djseleco's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Thank you received: 10
I have created an hidden field with this query to get usergroup by user:
//<code>
$my = & JFactory::getUser();
$db = JFactory::getDBO();
if($my->get('id')){
$id_utente = $my->get('id');
$db->setQuery("SELECT group_id FROM #__user_usergroup_map WHERE user_id=".$id_utente."");
$results = $db->loadObjectList();
foreach ($results as $res){
 return $res->group_id;
}
}
//</code>

But now i need to the script to redirect
Last Edit: 10 years 8 months ago by djseleco.
The administrator has disabled public write access.

set the Return URL based on usergroup 10 years 8 months ago #28603

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can edit the code below to suit your needs, you will have to change the group_id conditions from the if/else lines to match the groups of your scenario.
$db = JFactory::getDbo();
$user = JFactory::getUser();
 
//Create a query to grab the group id of the currently logged in user
 
$db->setQuery("SELECT `group_id` FROM #__user_usergroup_map WHERE `user_id`='". $user->get('id')."'");
$gid = $submissions = $db->loadResult();
 
//Define the scenario, for example Super User group id = 8 and Registered = 2
if ($gid == 8){
	$mainframe->redirect("http://1stredirect.com");
	}
else if ($gid == 2){
	$mainframe->redirect("http://2ndredirect.com");
	}

More information can be found in this article:
http://www.rsjoomla.com/support/documentation/view-article/602-php-scripts.html

PS: keep in mind that this is an example and not a solution.
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 10 years 8 months ago by cosmin.cristea.
The administrator has disabled public write access.

set the Return URL based on usergroup 10 years 8 months ago #28609

  • djseleco
  • djseleco's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Thank you received: 10
Perfect, works fine
Thanks Cosmin :)
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!