MyBB Community Forums

Full Version: Need Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sorry, if this is the wrong category.

I am developing a downloadable program that will interact with my site. To do this, I have to create new php files that interact with my forums. I need to know what code I will need to insert to do each of the following in my php files:
  • Verify a user's password
  • Retrieve a user's group ID
  • Retrieve a the custom profile field of a user

Anything else i need, i should be able to figure out from those. If you have any questions, please PM me. Thanks in advance.
Hello there...
I'm not how you will handle this, i mean if you are going to immitate the current function or use them as they are, but take not that if you are using them the way they are you should make your new page a part of MyBB rather than a part of your site because all these functions uses classes and variable and definitions from the whole MyBB system.

To make your page a part of MyBB, at the begining of the codes put

define("IN_MYBB", 1);
require_once "./global.php";

MyBB handle all verifications regarding a member in ./inc/functions_user.php, there you will be able to find all the functions you need.
Again if you are going to use the same codes, whether put a

require_once MYBB_ROOT."inc/functions_user.php";

After the codes that were mentioned a while ago, or copy the functions to a new page. (I recommend to use require).

In order to get the user group ID of a user you will have to run a query with the user ID.

As a part of MyBB
$query= $db->query("SELECT usergroup FROM ".TABLE_PREFIX."users WHERE uid='UID_VAR_HERE'");
$fetch = $db->fetch_array($query);
$usergroup = $fetch['usergroup'];

Not a part of MyBB
$query= mysql_query("SELECT usergroup FROM mybb_users WHERE uid='UID_VAR_HERE'");
$fetch = mysql_fetch_array($query);
$usergroup = $fetch['usergroup'];

To retrieve the custom profile fields, again a query with the user ID however this time to the userfields db table.

As a part of MyBB
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."userfields WHERE ufid='UID_VAR_HERE'");
$fetch = $db->fetch_array($query);
$field1 = $fetch['fid1'];
$field2 = $fetch['fid2'];

Not a part of MyBB
$query =mysql_query("SELECT * FROM mybb_userfields WHERE ufid='UID_VAR_HERE'");
$fetch = mysql_fetch_array($query);
$field1 = $fetch['fid1'];
$field2 = $fetch['fid2'];


Note that you will need to change the UID_VAR_HERE to the variable which you have that is holding the ID of the user needed to be checked. It can be passed in the query string or anyway.


regards
Thank you SOOOOOOOOO very much.
will this mod be available to everyone or are you making it just for your self.
Why do you need this as a mod anyway? 1st it wont work as a plugin, this is all external pages work. and all these functions are already a part of MyBB.

regards