Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14120 reviews 1680 hosting providers

Questions & Answers

Joomla user name variable in my URL

Sep 9, 2013 by jomnew
Hi,

I am using Joomla 3.1 and I want to know if it is possible to get the value of a specific user name when the user clicks a button directing him to another page. I want the user name to show under $value
this is the button code
<a class="link-button" href="ex.php?usrname=$value">

I would appreciate any help on this
Thanks

2 Answers

0 votes
Sep 9, 2013 by JoomAp
For getting a user object use this line of code
$user =JFactory::getUser();


To  create the link use the code
<a href="ex.php?username=<?php echo $user->username; ?>">your link goes here</a>


now you need to add this 'if' statement to make the username pass only if a user is either logged or if the user exists
<?php $var = ($user->usrid ? '?username='.$user->yourusername : ''); ?>
<a href="ex.php<?php echo $var ?>">your link goes here</a>
0 votes
Sep 9, 2013 by FixHost