MyBB-Plugins Forums
Custom Profile Fields - Printable Version

+- MyBB-Plugins Forums (http://forums.mybb-plugins.com)
+-- Forum: MyBB General Discussion (http://forums.mybb-plugins.com/Forum-MyBB-General-Discussion)
+--- Forum: Coding Help (http://forums.mybb-plugins.com/Forum-Coding-Help)
+--- Thread: Custom Profile Fields (/Thread-Custom-Profile-Fields)



Custom Profile Fields - audi9 - 06-17-2015

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


RE: Custom Profile Fields - Diogo Parrinha - 06-17-2015

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.


RE: Custom Profile Fields - audi9 - 06-17-2015

I get this error when I do that:

PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in DIR on line 41


RE: Custom Profile Fields - audi9 - 06-17-2015

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.


RE: Custom Profile Fields - Diogo Parrinha - 06-17-2015

Yeah there was a missing $ Wink


RE: Custom Profile Fields - audi9 - 06-19-2015

How would use a checkbox if statement so if FID4 was a checkbox how would you check if checked or if not checked?