• 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: Populating a drop down depending on user login.

Populating a drop down depending on user login. 15 years 6 months ago #8544

  • pauli
  • pauli's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I am trying to develop a competition entry form for our photographic website where the drop down list of possible entry classes is different for public viewers and registered members.

Eg If a user is logged in then the items in the select list are A, B, C & D but if the user is not logged in then only items A,B are displayed.

I am sure this is possible using the form on display script but I have no idea how.

Thanks in advance.
The administrator has disabled public write access.

Re:Populating a drop down depending on user login. 15 years 6 months ago #8597

  • bogdanc
  • bogdanc's Avatar
  • OFFLINE
  • Moderator
  • Posts: 669
  • Thank you received: 11
Hello,

You can use a script similar to this one in the Items box of the drop-down field in order to populate the drop-down list with different items for registered/not registered users:
//<code>
$items='1,2,3,4,5';
$isRegistered = $RSadapter->user();
if(!empty($isRegistered['id']))
{
$item_array=str_replace(",","\n",$items);
return $item_array;
}
else
{
$items='1,2,3';
$item_array=str_replace(",","\n",$items);
return $item_array;
}
//</code>

The first string '1,2,3,4,5' are the five items with which the drop-down list is populated if the user is registered. If the user is not registered the list is populate with the second string '1,2,3' .

Please note that the //<code> and //</code> tags are mandatory.
Last Edit: 15 years 6 months ago by bogdanc.
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!