• 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: Hide Fields If User Is Logged In

Hide Fields If User Is Logged In 11 years 4 months ago #20664

  • nelliott
  • nelliott's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hello,
I have some fields on my form that I would like to hide if a user is logged in. I am able to use PHP to test logged in status and return basic "logged in"/"not logged in" text, but I cannot figure out how to change the form. Any ideas?

Thanks,
Nelson
The administrator has disabled public write access.

Hide Fields If User Is Logged In 11 years 3 months ago #20679

  • nelliott
  • nelliott's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I have now figured out how to use javascript to hide the form fields, but I am still having trouble testing Logged In status within javascript.
The administrator has disabled public write access.

Hide Fields If User Is Logged In 11 years 3 months ago #20683

  • nelliott
  • nelliott's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Got it. I use the PHP section to dynamically generate a Javascript "hideFields" script that determines what fields to hide based on whether the user is logged in. Then, I include this little snippet in the Javascript section to run that script on page load:

window.addEvent('domready', function() {
hideFields();
});
The administrator has disabled public write access.

Hide Fields If User Is Logged In 10 years 6 months ago #25144

Hi,

I would very much appreciate if you could post your php in here...

I'm trying to hide the email field from a form if they are already logged in...

thanks!
The administrator has disabled public write access.

Hide Fields If User Is Logged In 9 years 10 months ago #27697

Hi there! Can anyone provide a detailed explanation, fellows?
The administrator has disabled public write access.

Hide Fields If User Is Logged In 9 years 8 months ago #28455

  • info3946
  • info3946's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Thank you received: 1
Hi Nelliott
Could you please let me know how you did this?
Thanks
The administrator has disabled public write access.

Hide Fields If User Is Logged In 9 years 7 months ago #28835

  • geral82
  • geral82's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
You can accomplish this by inserting this in the PHP Scripts:

$user = JFactory::getUser();
if($user->get('guest')==0){
$generateScript = "<script>
function hideFields() {
document.getElementById('fieldname1').style.display= 'none';
document.getElementById('fieldname2').style.display= 'none';
}
</script>
";
$formLayout.= $generateScript;
}

... replacing the "fieldname1" and "fieldname2" for your actual fields.

Regards!
The administrator has disabled public write access.

Hide Fields If User Is Logged In 9 years 7 months ago #28846

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
My help is not official customer support. To receive your support, submit a ticket by clicking here
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!