Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Double profile fields??


  • Naisai
    Participant

    @naisai

    Hi!

    I needed a country list for my sign-up form. I found this code on the net that fixed the problem, it created a “country field”. This meaning under User/ Profile field/Primary field . Once i edited the “country field” a new identical field showed up. They dont have a delete button and now I cannot remove any of the fields.

    I have tried:
    (1) Deleting the code
    (2) Deleting buddypress pluging incl. files. And then reInstall the plugin.

    Thank you for any feedback. I know nothing about codes.

Viewing 11 replies - 1 through 11 (of 11 total)

  • shanebp
    Moderator

    @shanebp

    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.


    Naisai
    Participant

    @naisai

    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?


    shanebp
    Moderator

    @shanebp

    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.


    Naisai
    Participant

    @naisai

    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 🙂


    shanebp
    Moderator

    @shanebp

    You can’t find the word Country in the function called ‘naisai_make_field_delete’ ???

    Can you find this WHERE name = in that function?


    Naisai
    Participant

    @naisai

    Okey! Then Im suppose to change ‘name’ into ‘country’ ? Dont get annoyed, I appreciate your help.


    Naisai
    Participant

    @naisai

    The field names are

    1. ‘country’
    2. ‘country(primary)’

    I only changed the description to a different language


    shanebp
    Moderator

    @shanebp

    Don’t change the name, just follow the directions about using the function.


    Naisai
    Participant

    @naisai

    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.


    shanebp
    Moderator

    @shanebp

    In the function, try changing Country to country.


    Naisai
    Participant

    @naisai

    Works perfectly. Thank you so much Shane!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] Double profile fields??’ is closed to new replies.
Skip to toolbar