MyBB Community Forums

Full Version: Variables?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just wanted to see if anyone could tell me how to get some of the variables.

I know the username is $user['username']

But what about things like whether they are a member or moderator or a admin.

I was just after these so I could work on a full featured Cash+Shop mod.

I plan on adding alot of variable features and the ability to allow certain things depending on their status as a [member/mod/supermod/admin] will matter.
There is the function

ismod -inc/functions.php
ismod($fid="0", $action="", $uid="0")

For the admin panel, you can use

checkadminpermissions - admin/adminfunctions.php
checkadminpermissions($action)

If you create a new admin permissions setting, it can be accessed from here. For example, create a new permission setting with the name 'access_panel' then using
checkadminpermissions('access_panel');
will either let the program continue or stop. This function does not return true or false, so you don't need to use if statements, which is annoying because I'd rather control the error than mybb.... but there you go.
checkadminpermissions("canuseei");
whoa thats confusing.

So how do you find out with a return?

You cant go,
if($user['level'] == "admin") {
allow to modify this.
} elseif($user['level'] == "moderator" {
allow to do this.
} else {
return false
}

Because, I dont think I could code it without the If statements.

Also, is it possible that, say a user accumulated enough 'cash'.

They could then buy access to a usergroup.
then with that usergroup, there is a dedicated section of the forums to them, so that only they can read it?

Another option I'm considering is the ability for a user to make people pay to have access to view an attachment. I think its possible but I still havent gotten around to finding the code that sets attachments.

I am also considering making people pay to add an attachment to their post. (stop people from adding mass attachments).

It would be nice to see where the attachments are sent to see if the code could be modded to send to a hosting space instead of the database. (read that somewhere in the forums here).

By the way, decswxaqz, im using your cashmod as a base to create my one. Smile
I'd wait until Gold is released. That was what I was going to do. No point in creating a big mod like this and then having to change it for Gold IMHO.

You can do that, but you should rely on MyBB's functions is possible. But in this instance...
Everything is possible. It's just a case of how much work you want to put into it Smile.

To put them in usergroup is easy. To make them pay and then get access isn't, but depends on how you implement it. You could create a simple PayPal thing, so that when a user clicks on donate button, it'll send them to PayPal to donate/pay and enter an entry in the DB telling you that they've gone to PayPal (and not paid). You could then either manually given them access to things, or you could create a nice fancy email parser that gets the person's email/user name and then gives them access automatically Smile hehe.

Just to let you know that there are some other people who are making their own CashMods so I'd be careful or how much work you put in in case they release it first (or a better one Wink).
hehe I know what you mean.

Im all confused because im used to phpBB.
Anyway, ill try what you said.
I might make a quick mod tonight. Nothing to do with this Toungue
You can use differing variables to get what you want. Right now I know of probably 2 ways of trying to check and see if a person is an admin:

$mybbgroup['cancp'] == "yes"
$user[usergroup] = 4 //#4 is the admins default usergroup number

You can do the same with the other membergroups such as supermods

$mybbgroup['issupermod'] == "yes"
sweet! thanks Cory. i might use the
$user['usergroup'] = 4

thanks for that.
If you're planning on making this a public modification, you might want to take the time to select the user's usergroup ID from the users table, and then select the usergroup's "cancp" field and check if that is set to "yes." Other usergroups can be Administrators as well so that is the best way to include all administrators, not just the ones in the default group.
And for future record, its actually $mybbuser['username'], not $user['username']. Heres a list of varibles to help you.

$mybbuser['uid'];
$mybbuser['username'];
$mybbuser['postnum'];
$mybbuser['usergroup'];
$mybbuser['avatar'];
$mybbuser['email'];
$mybbuser['usertitle'];

so modifying you code, it should look like this:
if($mybbuser['usergroup'] == "4") {
// allow to modify this.
} else if($mybbuser['usergroup'] == "6" || $mybbuser['usergroup'] == "3") {
// allow to do this.
} else {
return FALSE;
}
cool, thanks heaps guys.