Purchase Credits 2.0.1 released and NewPoints 2.1.2 released .
Custom Profile Fields
#1
Hello,

I need to use a custom profile field in my MyBB plugin. The id for the custom profile field is 4. It is a set of radio buttons one says: Yes? the other says No? They are to be used in a if statement. All the methods below don't work for some weird reason.

I have tried all of these:

    $useroptq = $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid=". (int)$user_info['uid']. "");
    $user_opt = $db->fetch_array($useroptq);
    
    $user_opt = $mybb->user['fid4'];
    
    $user_opt = $userfields['fid4'];
    
    $user_opt = $post['fid4'];
    
    $user_opt = $_GET['profile_fields[fid4]'];
    
    $user_opt = $GLOBALS['profile_fields']['fid4'];
   
    $user_opt = $_POST['profile_fields[fid4]']
    
    if ($user_opt == "Yes?") {
      //Do Stuffs
    }

I think i did the correct thing by adding this in the function?

    global $mybb, $db, $user_info, $userfields;

This is what the database looks like:
  http://i.stack.imgur.com/DpmTN.png

Thanks
Reply
#2
PHP Code:
$q db->simple_select('userfields''fid4''fid='.(int)$user_info['uid']);
$field $db->fetch_field($q'fid4'); 

Should put the value of the field in $field. If it doesn't work, make sure $user_info actually has a proper uid.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#3
I get this error when I do that:

PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in DIR on line 41
Reply
#4
Fixed it:
$useroptq = $db->query("SELECT fid4 FROM mybb_userfields WHERE ufid=". $user_id . "");
$user_opt = $db->fetch_array($useroptq, "fid4");
$user_opt = $user_opt["fid4"];

Thanks for your help. This forum is more helpful then the official mybb forum. You can Lock/Close thread.
Reply
#5
Yeah there was a missing $ Wink
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#6
How would use a checkbox if statement so if FID4 was a checkbox how would you check if checked or if not checked?
Reply





Users browsing this thread: 1 Guest(s)

About MyBB-Plugins

Plug Yourself into the best MyBB AddOn.

Copyright © 2009-2020 MyBB-Plugins Forums.

Statistics

  • 51,000+ Posts
  • 19,000+ Members
  • 3,600+ Threads

Impressed? For sure
Check Full Stats here