You should remove that code as soon the field is created.
If you edit the field name, then a new field will be created – if you don’t remove the code.
They dont have a delete button and now I cannot remove any of the fields.
That is because 'can_delete' => false,
should be 'can_delete' => true,
.
I have corrected the gist.
To delete the fields you already have, you can use a database tool like phpmyadmin.
You need to find the row(s) in the bp_xprofile_fields table and for each row, change the can_delete field value to 1. Then a ‘Delete’ will appear for that field in wp-admin.
Thank you so much!
You need to find the row(s) in the bp_xprofile_fields table and for each row, change the can_delete field value to 1
But what if I have already deleted the code? Should I then replace it and overwrite according to your corrections?
Don’t replace the code.
Use this function, and change ‘Country’ to the name you gave the field.
function naisai_make_field_delete() {
global $wpdb;
$table = $wpdb->prefix . "bp_xprofile_fields";
$wpdb->query( "UPDATE $table SET can_delete = 1 WHERE name = 'Country'" );
}
add_action( 'bp_ready', 'naisai_make_field_delete' );
Then visit your site’s home page.
Then go to that field in wp-admin and you should see a Delete link.
If you have more than one field you want to Delete, then change the name in the function and repeat the process.
When you are done – remove the function.
Then, if you want, get the code from the gist and run again.
Please forgive me if I seem slow-minded. But I know nothing about codes and need this broken down into dummies…
Use this function, and change ‘Country’ to the name you gave the field
How am I suppose to do this, because I cannot find the word ‘Country’ in the code you wrote. Should I change the function name ‘naisai_make_field_delete?
Thanks again 🙂
You can’t find the word Country
in the function called ‘naisai_make_field_delete’ ???
Can you find this WHERE name =
in that function?
Okey! Then Im suppose to change ‘name’ into ‘country’ ? Dont get annoyed, I appreciate your help.
The field names are
1. ‘country’
2. ‘country(primary)’
I only changed the description to a different language
Don’t change the name, just follow the directions about using the function.
You know what! Hahaha I didnt know you could scroll the code-box. So, I saw the word ‘country when I posted it into the buddypress editor. Silly me…
But unfortunately…it didnt work There are no delete buttons to the profile fields.
In the function, try changing Country to country.
Works perfectly. Thank you so much Shane!