I want to be able to insert the userid of the logged in user into an html string to an affiliate program . The idea being that when a registered user clicks on the shopping icon it will put his userid into the html string as the affiliate.
Is this possible? easily?

Comments

nedjo’s picture

So you can use it in a function like this:


function whatever() {
  global $user;

  $url = 'whatever/' . $user->uid;
 
  ...

}

}

Jay955528’s picture

Thanks,
Where would this work? Static Pages? Blogs? Do I need any other mocules running? I am just a cut and paste programmer so you can't insult me with too basic an explaination.
I am getting this error message

Parse error: parse error, unexpected '.' in /home/advance/public_html/drupal/includes/common.inc(1813) : eval()'d code on line 5

CnnmnSchnpps’s picture

If you are trying to get the user's name, use $user->name not $user->uid (which is the numerical user id)

This would work anywhere that you can execute php code (for example, a block that is configured to run php code, or while writing code for your own module)

Jay955528’s picture

Only in blocks not on the main page? My infantile understanding of drupal leads me to believe that a block can only be displayed on the sections to the left and righ of the main area.

dman’s picture

... that shows up on the front page.

If you are using PHPTemplate, just inline it where you want.

If you have a 'sticky' story at the top of your front, The content could have been entered using input-format:PHP.

Ditto if your front page is a specific node.

Dunno about other templates, I'm sure it can be done. Input-format:PHP Code.

.dan.

http://www.coders.co.nz/

scoonz’s picture

For accessing 'my account' you can also use user/profile or any user/blablabla like path - it will be redirected to user profile page.
Look here also: http://drupal.org/node/29000

--
Building bands and music communities sites, thanks to Drupal !
Ukrainian vocalists portal