XF 1.4 Custom Fields - unique


I have to implement a custom Field, which is easy to do with the great Admin Control Panel, but the difficult Thing is, that this custom field has to be unique.

Like the username in the Forum.

Out of the box there doesn`t seem to be a flag to set the field to "unique", so I thought to sove this via the "PHP Callback" function.

But I use Xenforo since yesterday and don`t have the experience.

In words I know what to do :)

  • Take the Content of the field, and execute a SELECT Query.
  • When nothing Comes back --> field is unique.
  • Otherwise, bring a message that the field is not unique.
But how to code this - not that I open a security whole.

I would be very happy if you could help me ;)

Greets Erich
@Jake Bunce
Thanks for your answer - I know that I have to use a php callback function.
I mentioned it in my 1st post.

But I don`t know whats the best and most secure way to Access the Database from the php?
Maybe someone can give me an Example.

How to initialize the DB Connection.
How to execute the SELECT Statement.

This would help me - and maybe more users.

I didn`t read one final solution to check for unique fields (not only custom onces) - also Twitter ID would be an example - in 3 hours searching the web for Xenforo :(

Greets Erich