1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom User Field Questions

Discussion in 'XenForo Questions and Support' started by Josiah, Jan 28, 2013.

  1. Josiah

    Josiah Member

    I have a few questions in regards of having a custom user field:

    1. How can I have a field be unique? As in, only one user can have the same value for the field, like a username.

    2. How can I have two fields to be required to run a php callback? Say, a field for username and field for password. Then, after the validation is made, to have only the username field show.

    3. How can I have "thank you" "error" when the field has been updated? I tried returning true with $error = 'Thank you for joining blah';
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    1) Use a callback:


    To verify the value against a user database you will need to connect to that database. Here is a code example for connecting to a database:


    This requires programming ability.

    2) There is no such option. That would require you to extend the register controller with an addon. That way you can verify the two fields together.

    3) Assuming you are referring to this callback:


    ...the error is only shown if you return false.
  3. Josiah

    Josiah Member

    1. Never saw the second link before. So I need query db::xf_user_field_value, correct?

    3. It is. So there is no way to show a message on true then in vanilla, that is, without an addon, correct?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If you want to ensure unique values for a profile field, then yes. Query that table to make sure no one else has entered the same value.


Share This Page