bp_dtheme_add_brackets_to_multiselectbox_attributes( $name )

Ensure that multiselect boxes have trailing brackets in their ‘id’ and ‘name’ attributes.


Description Description

These brackets are required for an array of values to be sent in the POST request. Previously, bp_get_the_profile_field_input_name() contained the necessary logic, but since BP 2.0 that logic has been moved into BP_XProfile_Field_Type_Multiselectbox. Since bp-default does not use the BP_XProfile_Field_Type classes to build its markup, it did not inherit the brackets from their new location. Thus this workaround.


Source Source

File: bp-themes/bp-default/functions.php

function bp_dtheme_add_brackets_to_multiselectbox_attributes( $name ) {
	global $field;

	if ( 'multiselectbox' === $field->type ) {
		$name .= '[]';
	}

	return $name;
}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.