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

force alphabetical listing of custom fields

Live Free

Active member
#1
I have over 100 custom field options that are not listed alphabetically. I'd like to list them alphabetically, from a-z, so users can select the proper field more easily (without thinking it's not an option). When I entered them I assumed it'd be alphabetical but it's not.

Is there anything I can do aside from re-entering them manually, which would be time-consuming? Perhaps a database query?

Thanks in advance.
 

Jake Bunce

XenForo moderator
Staff member
#3
You can run these queries to set all display orders on custom fields according to the alphabetical orders of the field_ids:

Code:
CREATE TABLE xf_user_field_order (
	`order` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	field_id VARCHAR(25) NOT NULL
);

INSERT INTO xf_user_field_order (field_id)
	SELECT uf.field_id
	FROM xf_user_field AS uf
	ORDER BY uf.field_id
	ASC;

UPDATE xf_user_field AS uf, xf_user_field_order AS ufo
SET uf.display_order = ufo.order
WHERE uf.field_id = ufo.field_id;

DROP TABLE xf_user_field_order;
 

Jake Bunce

XenForo moderator
Staff member
#4
Oh wait... are we talking about multiple custom fields? Or just one custom field with multiple options? These queries are for ordering multiple custom fields amongst themselves.