1
ManXP
Users variables
  • 2005/2/1 20:06

  • ManXP

  • Quite a regular

  • Posts: 231

  • Since: 2003/8/14


I'm another cool improvement for my website and i'm stuck a little. I want to remove XOOPS Login block from my website at all and move it to theme file. I made this type of login to work, but i need to generate theme automatically according to user, which is logged on. I need these 2 types - anonymous (not logged in) and normal user (logged in). Which variables should be used?

When i'm using this:

<{if $xoops_isadmin}>
code_for_theme_to_be_generated_automatically
<{/if}>

it works fine - when i log in as admin, i see generated template. Log out - don't see it. it's ok.

But when i'm using these variables

<{if !$xoopsUser}>
xxx
<{/if}> (whihc should work as anonymous)

and

<{if $xoopsUser}>
xxx
<{/if}> (normal user)

it doesn't work. Am i using bad variables?

2
ManXP
Re: Users variables
  • 2005/2/1 20:16

  • ManXP

  • Quite a regular

  • Posts: 231

  • Since: 2003/8/14


A little more explanation:

Actually it works, but if variable $xoopsUser is used, it's still used when i'm logged in as normal user. I mean, this code should be generated ONLY for anonymous, not for users. How to make it? Thank you.

3
Dave_L
Re: Users variables
  • 2005/2/1 20:31

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Use $xoops_isuser instead of $xoopsUser.

4
ManXP
Re: Users variables
  • 2005/2/1 20:59

  • ManXP

  • Quite a regular

  • Posts: 231

  • Since: 2003/8/14


Thank you so much for valuable tip!

Now i can remove login blovk, as everything works as needed.

Thanks again.

5
LazyBadger
Re: Users variables

Slightly different question, but - on topic... How to reach other user's info in theme? I want to show user's avatar, for example...

6
nachenko
Re: Users variables
  • 2005/4/19 18:29

  • nachenko

  • Quite a regular

  • Posts: 356

  • Since: 2005/1/18


I have a different but related problem.

I'm writing a custom PHP block and i need to check whether the user is registered or anonymous. It seems I can not use Smarty variables while in this custom block, so i tried:

if ($xoops_isuser == 1) {
blablabla...
}

The variable $xoops_isuser does not seem to exist, as I've tried:

echo ($xoops_isuser);

And got nothing on screen. I really need a way to check whether the user is registered or guest. I've tried reading $_COOKIES for the session cookie but the son of a ... Internet Explorer does not delete the cookies after closing, as it was expected. I hate IE, but too many people use it, so i need another solution.

Any ideas please?

7
Dave_L
Re: Users variables
  • 2005/4/19 18:56

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Don't confuse PHP variables and Smarty template variables. In a custom PHP block, use:

global $xoopsUser;
if (
is_object($xoopsUser)) {


or

global $xoopsUser;
if (
$xoopsUser) {

8
nachenko
Re: Users variables
  • 2005/4/19 22:28

  • nachenko

  • Quite a regular

  • Posts: 356

  • Since: 2005/1/18


It works.

Again this forum saved my life.

BTW, i've read some about "global" keyword in PHP.net. It's a bit confusing to me, as the scope of the variables is different from ActionScript, which is the language I know most.

Thank you.

Login

Who's Online

294 user(s) are online (177 user(s) are browsing Support Forums)


Members: 0


Guests: 294


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