I'm working with Linx a links submission component, which is great but I'd like to modify it slightly:
where it asks you to enter your name in a field, i'd like it to hard code the users (user)name:
This is from the php file and creates the fields to fill stuff in:
$recip_url = mosGetParam( $_REQUEST, 'recip_url', '' );
$new_url = mosGetParam( $_REQUEST, 'new_url', '' );
$new_url_name = mosGetParam( $_REQUEST, 'new_url_name', '' );
$new_url_description = mosGetParam( $_REQUEST, 'new_url_description', '' );
$new_name = mosGetParam( $_REQUEST, 'new_name', '' );
$new_email = mosGetParam( $_REQUEST, 'new_email', '' );
$cat_id = mosGetParam( $_REQUEST, 'cat_id', '' );
I'd like to replace this:
$new_name = mosGetParam( $_REQUEST, 'new_name', '' );
with something that calls the (user)name instead of the field.
I grabbed this from the debug when opening a (community builder) profile page:
7
SELECT id, name, email, block, sendEmail, registerDate, lastvisitDate, activation, params
FROM jos_users
WHERE id = 62
I tried echo statements, but all i got was errors, what should I do?
Customising a component: call a username
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
-
- Joomla! Apprentice
- Posts: 7
- Joined: Fri Jun 08, 2007 3:14 pm
Re: Customising a component: call a username
In J!1.0 you need to use:
In J!1.5 you need to use:
Hope this helps.
StuG
Code: Select all
global $my;
$userid = $my->id;
$username = $my->username;
Code: Select all
$user =& JFactory::getUser();
$userid = $user->get('id');
$username = $user->get('username');
StuG
Last edited by macbloke on Sun Feb 24, 2008 7:24 pm, edited 1 time in total.
-
- Joomla! Apprentice
- Posts: 7
- Joined: Fri Jun 08, 2007 3:14 pm
Re: Customising a component: call a username
Hey stu, thanks for the first step ...
I tried copying that in the php doc...and got an error:
Guess I should have done something different?
(maybe a touch of back ground will help:
The is the linx component, and hat I want to happen is that instead of a user being asked to fill in a name, it's automatically filled in for him so there is no chance of "fudging")
I tried copying that in the php doc...and got an error:
Code: Select all
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in D:\Website\xampp\htdocs\nedgolfvet\components\com_linx\linx.php on line 203
(maybe a touch of back ground will help:
The is the linx component, and hat I want to happen is that instead of a user being asked to fill in a name, it's automatically filled in for him so there is no chance of "fudging")
Re: Customising a component: call a username
You're missing a ';' from the end of one of the lines. Check you've got them all complete and you should be good to go.
Regards,
StuG
Regards,
StuG
Re: Customising a component: call a username
If you're copying directly, you might want to use:
in lieu of your mosGetParam request.
StuG
Code: Select all
$new_name = $username;
StuG
-
- Joomla! Apprentice
- Posts: 7
- Joined: Fri Jun 08, 2007 3:14 pm
Re: Customising a component: call a username
thanks i'll try it at once!