[buddypress-trac] [BuddyPress Trac] #5472: xprofile_insert_field -> type - 'option' not allowed?

buddypress-trac noreply at wordpress.org
Sun Jun 15 20:49:37 UTC 2014


#5472: xprofile_insert_field -> type - 'option' not allowed?
------------------------------+---------------------------
 Reporter:  shanebp           |       Owner:  boonebgorges
     Type:  defect (bug)      |      Status:  reopened
 Priority:  normal            |   Milestone:  2.1
Component:  XProfile          |     Version:  1.9.2
 Severity:  normal            |  Resolution:
 Keywords:  needs-unit-tests  |
------------------------------+---------------------------

Comment (by shanebp):

 Versions:
 - WP: 3.9.1
 - theme 2013
 - BP: trunk
 - PHP 5.4.28
 - MYSQL: 5.5.37

 No other plugins.

 This function is the only thing in bp-custom.php:

 {{{

 function bp_add_custom_country_list() {

   if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup'
 == $_GET['page'] ) {

                 $country_list_args = array(
                        'field_group_id'  => 1,
                        'name'            => 'Country',
                        'description'     => 'Please select your country',
                        'can_delete'      => false,
                        'field_order'     => 2,
                        'is_required'     => false,
                        'type'            => 'selectbox',
                        'order_by'            => 'default'

                 );

                 $country_list_id = xprofile_insert_field(
 $country_list_args );

                 if ( $country_list_id ) {

                         $countries = array(
                                 "United States",
                                 "Afghanistan",
                                 "Albania",
                                 "Algeria",
                                 "Andorra",
                                 "Angola"
                         );

                         $i = 0;

                         foreach (  $countries as $country ) {

                                 xprofile_insert_field( array(
                                         'field_group_id'        => 1,
                                         'parent_id'             =>
 $country_list_id,
                                         'type'                  =>
 'option',
                                         'name'                  =>
 $country,
                                         'option_order'   => $i
                                 ));
                                 $i++;

                         }

                 }
         }
 }
 add_action('bp_init', 'bp_add_custom_country_list');
 }}}

 - I navigate to wp-admin/users.php?page=bp-profile-setup
 - the script runs
 - for every row 'option_order' is zero ( the default value for that field)
 - if I hard-code 'option_order' to 123, it still gets saved as zero
 - for what it's worth: if I add 'field_order' => $i, the correct values
 are stored in the field_order column

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5472#comment:21>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list