MyBB Community Forums

Full Version: variable help pls (important)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
BİG THANKS "Michael83"
your post was helped me. it is reference for me.
can you say something for my new question???


this code take username in our mybb:

define("KILL_GLOBALS", 1);

require "./global.php";

// take user name in mybb
$username = $mybb->user['username'];

print "Welcome, $username" ;

my new question:
how can I take Administrators, Super Moderators, Moderators, Registered and sex (male or female)...

example:
$any = $mybb->?????????????????

print "you are $any" ; (example: you are administrators)


pls help me Sad
I need your helps...
it is too important for me Sad
this code take username in our mybb:

define("KILL_GLOBALS", 1);

require "./global.php";

// take user name in mybb
$username = $mybb->user['username'];

print "Welcome, $username" ;

in blank page this code write Welcome Alep (alep my username)

my question:
how can I take Administrators, Super Moderators, Moderators, Registered and sex (male or female)...

example:
$any = $mybb->?????????????????

print "you are $any" ; (example: you are administrators)



pls help me Sad
I need your helps...
it is too important for me Sad
Any feild inside the users table can be called by $mybb->user

Also, the $mybbuser variable has the same effect in the templates.
For the usergroup:
switch ($mybb->user['usergroup']) {
case "1":
   $usergroup = "Not logged in";
   break;
case "2":
   $usergroup = "Member";
   break;
case "3":
   $usergroup = "Admin";
   break;
}
$mybb->user['usergroup'] returns the ID of the usergroup. You have to associate the name of the group to the ID. You can use the code above or you can use a query to get the name from the table usergroups by ID.

To get the sex of a user you have to get the information from the database table profilefields by using a query.
alep Wrote:my question:
how can I take Administrators, Super Moderators, Moderators, Registered and sex (male or female)...

example:
$any = $mybb->?????????????????

print "you are $any" ; (example: you are administrators)

You can try something like:
echo "you are in the ".$mybb->usergroup['title']." usergroup!";
thanks for your posts.
could you tell me how can I know the user is male or female???

example:
echo "you are in the ".$mybb->usergroup['title']." usergroup!";

and you are male...
"Michael83"
thank you very much...
you are answered my question already...
you are helpfull Smile

I am sory but I don't understand male or female query...
could you tell me how can I this query?
You can use something like this:
$query = $db->query("SELECT fid3 FROM ".TABLE_PREFIX."userfields WHERE ufid = '".$mybb->user['uid']."'");
$sex = $db->fetch_array($query);
echo "... and you are ".$sex['fid3'];
"Michael83"
thank you friend you are the best and one Cool
You are very intelligent Rolleyes
thanks thanks thanks Big Grin
I did with your helps
thaksgiving
oh no...
how can I echo ip address this user Sad
I know I am problem boy Sad
Michael83: FYI, $mybb->user already contains all the userfields. Wink

alep: To show the IP address, I'd recommend using $_SERVER['REMOTE_ADDR']. This is predefined by PHP, and can't be spoofed. If you want the IP address detected by MyBB, use $session->ipaddress.
Pages: 1 2