BuddyDev

Search

Cannot remove country field added to buddypress extended profile fields by code

  • Participant
    Level: Enlightened
    Posts: 33
    Nestor Djintelbé on #36432

    Hi buddydev team,

    I used the code below to add the country field to my buddypress extended profile fields.

    
    <?php
    /**
     * If you are using BP 2.1+, this will insert a Country selectbox.
     * Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
     */
    
    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'	 => 'custom'
     
    		);
     
    		$country_list_id = xprofile_insert_field( $country_list_args );
     
    		if ( $country_list_id ) {
     
    			$countries = array(
    				"United States",			
    				"Afghanistan",
    				"Albania",
    				"Algeria",
    				"Andorra",
    				"Angola",
    				"Antigua and Barbuda",
    				"Argentina",
    				"Armenia",
    				"Australia",
    				"Austria",
    				"Azerbaijan",
    				"Bahamas",
    				"Bahrain",
    				"Bangladesh",
    				"Barbados",
    				"Belarus",
    				"Belgium",
    				"Belize",
    				"Benin",
    				"Bhutan",
    				"Bolivia",
    				"Bosnia and Herzegovina",
    				"Botswana",
    				"Brazil",
    				"Brunei",
    				"Bulgaria",
    				"Burkina Faso",
    				"Burundi",
    				"Cambodia",
    				"Cameroon",
    				"Canada",
    				"Cape Verde",
    				"Central African Republic",
    				"Chad",
    				"Chile",
    				"China",
    				"Colombi",
    				"Comoros",
    				"Congo (Brazzaville)",
    				"Congo",
    				"Costa Rica",
    				"Cote d'Ivoire",
    				"Croatia",
    				"Cuba",
    				"Cyprus",
    				"Czech Republic",
    				"Denmark",
    				"Djibouti",
    				"Dominica",
    				"Dominican Republic",
    				"East Timor (Timor Timur)",
    				"Ecuador",
    				"Egypt",
    				"El Salvador",
    				"Equatorial Guinea",
    				"Eritrea",
    				"Estonia",
    				"Ethiopia",
    				"Fiji",
    				"Finland",
    				"France",
    				"Gabon",
    				"Gambia, The",
    				"Georgia",
    				"Germany",
    				"Ghana",
    				"Greece",
    				"Grenada",
    				"Guatemala",
    				"Guinea",
    				"Guinea-Bissau",
    				"Guyana",
    				"Haiti",
    				"Honduras",
    				"Hungary",
    				"Iceland",
    				"India",
    				"Indonesia",
    				"Iran",
    				"Iraq",
    				"Ireland",
    				"Israel",
    				"Italy",
    				"Jamaica",
    				"Japan",
    				"Jordan",
    				"Kazakhstan",
    				"Kenya",
    				"Kiribati",
    				"Korea, North",
    				"Korea, South",
    				"Kuwait",
    				"Kyrgyzstan",
    				"Laos",
    				"Latvia",
    				"Lebanon",
    				"Lesotho",
    				"Liberia",
    				"Libya",
    				"Liechtenstein",
    				"Lithuania",
    				"Luxembourg",
    				"Macedonia",
    				"Madagascar",
    				"Malawi",
    				"Malaysia",
    				"Maldives",
    				"Mali",
    				"Malta",
    				"Marshall Islands",
    				"Mauritania",
    				"Mauritius",
    				"Mexico",
    				"Micronesia",
    				"Moldova",
    				"Monaco",
    				"Mongolia",
    				"Morocco",
    				"Mozambique",
    				"Myanmar",
    				"Namibia",
    				"Nauru",
    				"Nepal",
    				"Netherlands",
    				"New Zealand",
    				"Nicaragua",
    				"Niger",
    				"Nigeria",
    				"Norway",
    				"Oman",
    				"Pakistan",
    				"Palau",
    				"Panama",
    				"Papua New Guinea",
    				"Paraguay",
    				"Peru",
    				"Philippines",
    				"Poland",
    				"Portugal",
    				"Qatar",
    				"Romania",
    				"Russia",
    				"Rwanda",
    				"Saint Kitts and Nevis",
    				"Saint Lucia",
    				"Saint Vincent",
    				"Samoa",
    				"San Marino",
    				"Sao Tome and Principe",
    				"Saudi Arabia",
    				"Senegal",
    				"Serbia and Montenegro",
    				"Seychelles",
    				"Sierra Leone",
    				"Singapore",
    				"Slovakia",
    				"Slovenia",
    				"Solomon Islands",
    				"Somalia",
    				"South Africa",
    				"Spain",
    				"Sri Lanka",
    				"Sudan",
    				"Suriname",
    				"Swaziland",
    				"Sweden",
    				"Switzerland",
    				"Syria",
    				"Taiwan",
    				"Tajikistan",
    				"Tanzania",
    				"Thailand",
    				"Togo",
    				"Tonga",
    				"Trinidad and Tobago",
    				"Tunisia",
    				"Turkey",
    				"Turkmenistan",
    				"Tuvalu",
    				"Uganda",
    				"Ukraine",
    				"United Arab Emirates",
    				"United Kingdom",
    				"Uruguay",
    				"Uzbekistan",
    				"Vanuatu",
    				"Vatican City",
    				"Venezuela",
    				"Vietnam",
    				"Yemen",
    				"Zambia",
    				"Zimbabwe"
    			);
    			
    			foreach (  $countries as $country ) {
    				
    				xprofile_insert_field( array(
    					'field_group_id'	=> 1,
    					'parent_id'		=> $country_list_id,
    					'type'			=> 'option',
    					'name'			=> $country,
    					'option_order'   	=> $i++
    				));
    				
    			}
     
    		}
    	}
    }
    add_action('bp_init', 'bp_add_custom_country_list');
    

    I am trying to delete the field but I cannot. I removed the code but the field is still there. I also tried to hide the field using a css code; a part of the field is just hiden and after removing the css code, the hiden part did not come back.

    It seems that the matter is on the fact that can_delete is put to false ( 'can_delete' => false) in country_list_arg array; I did not care about that.

    So, how can I delete it? I am asking for your help please.

    Regards

    Nestor

You must be logged in to reply to this topic.

This topic is: not resolved