Hi,
I have a javascript code for my form which I want to edit secionts of it based on my user status. What I mean is:
If user is signed in Execute A
If user is Not signed in Execute B
How can I do this?
Thanks
I have a javascript code for my form which I want to edit secionts of it based on my user status. What I mean is:
If user is signed in Execute A
If user is Not signed in Execute B
How can I do this?
Thanks
Hi omidhz,
Put the user->id (or user->guest) into a hidden field. Then you can check the value with your script.
Bob
Put the user->id (or user->guest) into a hidden field. Then you can check the value with your script.
Bob
Could you please explain how I can do this? I'm not really sure how to check the value?
Hi omidhz,
In your form html you need to add this at the end
Bob
In your form html you need to add this at the end
<?php
if ( !$mainframe->isSite() ) { return; }
$user = & JFactory ::getUser();
?>
<input type='hidden' name='user_id' value='<?php echo $user->id; ?>' />Bob
Thank you for your quick reply. I will try this and get back to you. I think it should work just fine for what I need.
I have a small issue here. The above code is php so it loads with the form. My calculation is in javascript which loades before the form. What I need is to have a javascript if...else command.
if use is registered run A if not registered run B. How I can use the above code in javascript?
I really appreciate your support.
if use is registered run A if not registered run B. How I can use the above code in javascript?
I really appreciate your support.
Hi omidhz,
None of your scripts *should* run before the form loads; so add an id and check in the script for the value of the hidden field.
Bob
None of your scripts *should* run before the form loads; so add an id and check in the script for the value of the hidden field.
<input type='hidden' name='user_id' id='user_id' value='<?php echo $user->id; ?>' />var user_id = $('user_id').value;Bob
This topic is locked and no more replies can be posted.
