1
Shiroku
user id, can I get it?
  • 2006/9/24 12:49

  • Shiroku

  • Just popping in

  • Posts: 33

  • Since: 2006/9/24


I created a new table in my DB, and I created a members' form (the form is showed after the users logged in).

In my new table, there is a column 'user-id' that will contain the user id of the user that logged in (the 'uid' column of the table called xoops_user).

How can I get this value?
How can I know who is the members that will compile the form?


PS: I'm sorry for my English...

2
rplima2004
Re: user id, can I get it?
  • 2006/9/24 13:44

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Hi Shiroku,


To get the id of loged in user is simple.

Quote:

###########################################################################################
#### Hack in the file header.php to send to theme.html informations about logged in user.
#### by TheRpLima
#### data: 05/09/2006
#### Usage Example:
####

#### <{if $user.name == ""}>
####

Hi <{$user.uname}>, your profile still was uncomplete, please click here to complete it.


#### <{/if}>
####

####
###########################################################################################
if ($xoopsUser){
foreach($xoopsUser->vars as $key=>$value){
$user[$key] = $value;
}
foreach($user as $key=>$value){
foreach($user[$key] as $key1=>$value1){
if ($key1 == 'value')
$user[$key] = $value1;
}
}
$xoopsTpl->assign('user',$user);
}

In the example above, i was send the information of logged in user to theme.hmtl. In your case, only substitute the $xoopsTpl->assign('user',$user); for the code to save the data in db. The $user variable is an array of user information like this.
Quote:

Array
(
[uid] => 1
[name] =>
[uname] => admin
[email] => admin@brinfo.com.br
[url] =>
[user_avatar] => blank.gif
[user_regdate] => 1158207394
[user_icq] =>
[user_from] =>
[user_sig] =>
[user_viewemail] => 1
[actkey] =>
[user_aim] =>
[user_yim] =>
[user_msnm] =>
[pass] => e10adc3949ba59abbe56e057f20f883e
[posts] => 0
[attachsig] => 0
[rank] => 7
[level] => 5
[theme] => xmbluext1
[timezone_offset] => 0.0
[last_login] => 1159106474
[umode] => thread
[uorder] => 0
[notify_method] => 1
[notify_mode] => 0
[user_occ] =>
[bio] =>
[user_intrest] =>
[user_mailok] => 0
)


I hope this help you.

TheRplima

3
nekro
Re: user id, can I get it?
  • 2006/9/24 17:02

  • nekro

  • Quite a regular

  • Posts: 213

  • Since: 2005/11/9


try to use the nex code... very simple...

//Make an XoopsUser object giving the user Id as Variable

$otherUser = XoopsUser( $theIdfromTheTable );

//Now you can get all the info from the user whith the getVar method.

$otherUname = $otherUser->getVar( 'uname' );

$otherEmail = $otherUser->getVar( 'email' );

4
rplima2004
Re: user id, can I get it?
  • 2006/9/24 19:07

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Yes nekro,

this code functions but what it wants it is exactly to get id of the user and with this code it already needs to have id in hands.

TheRplima

5
nekro
Re: user id, can I get it?
  • 2006/9/24 19:27

  • nekro

  • Quite a regular

  • Posts: 213

  • Since: 2005/11/9


Ups!... i ve understand in a wrong way!... sorry...


AHH! and it is my 100 post!!!... congratz for me!

6
Shiroku
Re: user id, can I get it?
  • 2006/9/25 9:40

  • Shiroku

  • Just popping in

  • Posts: 33

  • Since: 2006/9/24


thank's!

In my case, if I want show the user id in the page, I have to substitute the
$xoopsTpl->assign('user',$user);

for
echo $user['uid'];


Is it right?

7
rplima2004
Re: user id, can I get it?
  • 2006/9/25 12:10

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


It depends on the page that you want to show this. If template will be that use of the skill that I post, if a page in php only of the skill that you post.

Make tests and any trouble post here again.

TheRplima

8
Saganxis
get the user id
  • 2006/9/27 1:56

  • Saganxis

  • Just popping in

  • Posts: 25

  • Since: 2006/7/20


Well i think it will be easier to do

$uId = $xoopsUser->getVar('uid');
xoopsTpl->assign('id',$uId);

9
rplima2004
Re: get the user id
  • 2006/9/27 3:01

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Quote:

Saganxis wrote:
Well i think it will be easier to do

$uId = $xoopsUser->getVar('uid');
xoopsTpl->assign('id',$uId);


Yes someone, of this skill certainly is simpler. I only showed an easy skill of he get all the data of the user. The two ways are correct depend alone on what it will be to make

10
Shiroku
Re: get the user id
  • 2006/9/30 11:19

  • Shiroku

  • Just popping in

  • Posts: 33

  • Since: 2006/9/24


thank's, thank's, thank's!

This is the code that I used:

if ($xoopsUser){
 foreach(
$xoopsUser->vars as $key=>$value){
 
$user[$key] = $value;
 }
 foreach(
$user as $key=>$value){
 foreach(
$user[$key] as $key1=>$value1){
 if (
$key1 == 'value')
 
$user[$key] = $value1;
 }
 }
 echo 
"Your user id is: ".$user['uid'];
}
?>



bye

Login

Who's Online

310 user(s) are online (252 user(s) are browsing Support Forums)


Members: 0


Guests: 310


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits