Display {USER_NAME} and {USER_GROUP} in anycontent.php Display {USER_NAME} and {USER_GROUP} in anycontent.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Display {USER_NAME} and {USER_GROUP} in anycontent.php

Started by Mimer, October 24, 2007, 03:21:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mimer

How can I display {USER_NAME} and {USER_GROUP} values in anycontent.php?

After searching the forum I've tried adding:
require('include/init.inc.php');
That didn't work.

Then I've tried using quotation marks "{USER_NAME}" and "{USER_GROUP}" and that didn't work.

Mimer  8)

More code:
if (USER_GROUP=='Registered') {
        starttable("100%", "<b>Registered Member</b>");

        ?>
        <tr><td class="tableb" >
        Hello {USER_NAME} <br /><br />
        You're currently logged in as {USER_GROUP} Member.<br />
You have access to all pictures in the gallery. <br />
In the category Registred Members Galleries you have your own category {USER_NAME} where you can create your own Albums to upload your own files.<br />
Your Albums can hold 20 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer<br /><br />
Credits goes to all the beautiful women in the galleri and all the people who made the hardwork<br />
Special thanks goes to Fjotte, fjoske, nsewerin, ripley, since84 and all members at fjotte.dk
</td></tr>
        <?php
        endtable
();
}

Sami

It doesn't works that way !
First of all you don't need to include any files cause those are constant and global

Either use php's echo/print to output USER_NAME/USER_GROUP, something like this

<tr><td class="tableb" >
        Hello <?php echo USER_NAME?> <br /><br />
        You're currently logged in as <?php echo USER_GROUP?> Member.<br />
You have access to all pictures in the gallery. <br />
In the category Registred Members Galleries you have your own category <?php echo USER_NAME?> where you can create your own Albums to upload your own files.<br />
Your Albums can hold 20 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer<br /><br />
Credits goes to all the beautiful women in the galleri and all the people who made the hardwork<br />
Special thanks goes to Fjotte, fjoske, nsewerin, ripley, since84 and all members at fjotte.dk
</td></tr>


or use heredoc syntax

if (USER_GROUP=='Registered') {
        starttable("100%", "<b>Registered Member</b>");
$user_name = USER_NAME;
$user_group = USER_GROUP;
echo<<<EOT

        <tr><td class="tableb" >
        Hello {$user_name} <br /><br />
        You're currently logged in as {$user_group} Member.<br />
You have access to all pictures in the gallery. <br />
In the category Registred Members Galleries you have your own category {$user_name} where you can create your own Albums to upload your own files.<br />
Your Albums can hold 20 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer<br /><br />
Credits goes to all the beautiful women in the galleri and all the people who made the hardwork<br />
Special thanks goes to Fjotte, fjoske, nsewerin, ripley, since84 and all members at fjotte.dk
</td></tr>

EOT;

        endtable();
}


for more info about php string please read this
http://www.tizag.com/phpT/strings.php
‍I don't answer to PM with support question
Please post your issue to related board

Mimer


Joachim Müller

Clarification: the custom tokens in curly brackets that may exist in theme.php can't be re-used outside of the function that has the definition of those placeholder tokens.

Mimer

Thanks for the clarification. I learn by the hour.

Well, could I somehow define $user_name = USER_NAME; $user_group = USER_GROUP; once, since I use them several time in the script.
Just to clean up code.

Mimer  8)

Full code:
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

if (!USER_ID) {
        starttable("100%", "<b>Not Logged In</b>");
$user_group = USER_GROUP;
echo<<<EOT
        <tr><td class="tableb" >
        Hello {$user_group}<br />
        You're currently not logged in. You must be a member of the danish forum <a href="http://fjotte.dk/site/">fjotte.dk</a> to access this gallery.<br />
        Sign up for free <a href="http://fjotte.dk">here</a>. If you already are a member and have a login then log in <a href="login.php">here</a> or in the menu at top.<br /><br />
Mimer
        </td></tr>

EOT;

        endtable();
} else if (USER_GROUP=='Administrators') {
        starttable("100%", "<b>Administrator Mode</b>");
$user_name = USER_NAME;
$user_group = USER_GROUP;
echo<<<EOT

        <tr><td class="tableb" >
        Hello {$user_name} <br />
        You're in full control. <br /><br />
Mimer
        </td></tr>

EOT;

        endtable();
} else if (USER_GROUP=='Supporter') {
        starttable("100%", "<b>Supporter</b>");
$user_name = USER_NAME;
$user_group = USER_GROUP;
echo<<<EOT

        <tr><td class="tableb" >
        Hello {$user_name} <br />
        You're currently logged in as Exclusive Member and {$user_group}. You have access to all pictures in the gallery in High Resolution and all videos.<br />
In the category "Registred Members Galleries" you have your own category "{$user_name}" where you can create your own Albums to upload your own files.<br />
Your Albums can hold 100 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer
</td></tr>

EOT;

        endtable();
} else if (USER_GROUP=='Exclusive') {
        starttable("100%", "<b>Exclusive Member</b>");
$user_name = USER_NAME;
$user_group = USER_GROUP;
echo<<<EOT

        <tr><td class="tableb" >
        Hello {$user_name} <br />
        You're currently logged in as {$user_group} Member. You have access to all pictures in the gallery in High Resolution and all videos.<br />
In the category "Registred Members Galleries" you have your own category "{$user_name}" where you can create your own Albums to upload your own files.<br />
Your Albums can hold 50 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer
</td></tr>

EOT;

        endtable();
} else if (USER_GROUP=='Registered') {
        starttable("100%", "<b>Registered Member</b>");
$user_name = USER_NAME;
$user_group = USER_GROUP;
echo<<<EOT

        <tr><td class="tableb" >
        Hello {$user_name} <br /><br />
        You're currently logged in as {$user_group} Member. You have access to all pictures in the gallery. <br />
In the category "Registred Members Galleries" you have your own category "{$user_name}" where you can create your own Albums to upload your own files.<br />
Your Albums can hold 20 MB. Make the Albums public or private or protect it with a password for other Members.<br />
Please only post Danish Celebrities in this gallery. Post your International Celebrities <a href="http://fjotte.dk/gal_in/">here</a><br /><br />
Mimer
</td></tr>

EOT;

        endtable();
}


Joachim Müller

What would be the point of defining a constant? Once the var is populated, it never is being unset. So you either have the var populated (then the constant will be populated as well) or you don't have it pupulated (the the constant will be empty as well). There's no benefit in populating the constant. You can use the $user_data array just about anywhere (after it has been populated in the first place) - just make it global if you call it from within a function.