MyBB Community Forums

Full Version: How could I check if a custom field already exists?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Say that, like usernames, I don't want a custom field to be reused.

Is there a way to add this easily?

Thank you for any help.
This is really easy.

if($db->field_exists($field, $table))
{
// do something;
}
else
{
// do something else;
}
(2016-09-19, 09:19 PM)dragonexpert Wrote: [ -> ]This is really easy.

if($db->field_exists($field, $table))
{
// do something;
}
else
{
// do something else;
}

Where would I insert it into is more of my question :Big Grin Thank you so much dragonexpert!!!!
Plugins are suppose to have database changes handled in the _install function for adding fields and removing fields and tables in the _uninstall function. You globalize the variable $db to give you access to the database class and its methods.