bp_dtheme_add_brackets_to_multiselectbox_attributes

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

Description

bp_dtheme_add_brackets_to_multiselectbox_attributes( (string) $name ); 

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" title="BP_XProfile_Field_Type_Multiselectbox" class="code class">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.

Parameters (1)

0. $name (string)
The name.

Usage

  1. if ( !function_exists( 'bp_dtheme_add_brackets_to_multiselectbox_attributes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-themes/bp-default/functions.php'; 
  3.  
  4. // The name. 
  5. $name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_dtheme_add_brackets_to_multiselectbox_attributes($name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-themes/bp-default/functions.php  
  1. function bp_dtheme_add_brackets_to_multiselectbox_attributes( $name ) { 
  2. global $field; 
  3.  
  4. if ( 'multiselectbox' === $field->type ) { 
  5. $name .= '[]'; 
  6.  
  7. return $name;