MyBB Community Forums

Full Version: Help with my first plugin for MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
-----
-----
Try something along the lines of this - it ought to work:

function *_activate() 
{
	global $db;

	/*
	* Add a new profile field
	*/
	$profilefield = array(
		"fid"			=> "",
		"name"			=> "MYPROFILEFIELD",
		"description"	=> "MYPROFILEFIELD DESCRIPTION",
		"type"			=> "text",
		"maxlength"		=> "50",
		"editable"		=> "1",
		"hidden"		=> "1",
	);
	
	$db->insert_query("profilefields", $profilefield);
	$pfid = $db->insert_id();
	$db->query("ALTER TABLE ".TABLE_PREFIX."userfields ADD `fid{$pfid}` TEXT");
}

function *_deactivate()
{
	global $db;
	
	/*
	*	Remove profile field
	*/
	$pfid = $db->fetch_field($db->simple_select('profilefields', 'fid', 'name=\'MYPROFILEFIELD\''), 'fid');
	$db->delete_query('profilefields', 'name=\'MYPROFILEFIELD\'');
	$db->query('ALTER TABLE '.TABLE_PREFIX.'userfields DROP COLUMN fid'.$pfid';');
}
-----
If you PM me your whole code, I'll take a quick look - it'd be easier that way Wink
-----