Skip to:
Content
Pages
Categories
Search
Top
Bottom

Delete an existing registration field and impact in database


  • telesemana
    Participant

    @telesemana

    A while ago I created a field in my registration page called “country” so user in my buddy press install would write their country. That was really badly planned as people are writing their country name in different forms. I want now to replace that field with a dropdown menu and my question is: if a remove the existing field from the registration page, would I delete also all the information on the database? Many thanks.

    I am using the latest WordPress and buddypress versions.

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

  • shanebp
    Moderator

    @shanebp

    When a xprofile field is deleted, the field meta data and each member’s data re that field is NOT deleted.

    But the data is orphaned – iow. the data is related to a field ID that no longer exists.


    telesemana
    Participant

    @telesemana

    Hi shanebp, what would be then the best way to do this. That is to remove the text filed by a drop down? Any easy fix?
    Thanks for your quick reply.


    shanebp
    Moderator

    @shanebp

    It’s a delicate fix.
    Backup your database first.

    Then try this…

    Don’t delete the current field – Change it to a selectbox.
    Note the field_id ( in the wp-admin url )

    Then adapt and run this function to add countries:
    https://gist.github.com/shanebp/119ffd879acc56c324ab

    Use these parts:

    $countries = array( ... ); 
    
    foreach (  $countries as $country ) {
    	
    	xprofile_insert_field( array(
    		'field_group_id'	=> 1,
    		'parent_id'		=> 28,  // the field_id of the field
    		'type'			=> 'option',
    		'name'			=> $country,
    		'option_order'   	=> $i++
    	));
    	
    }

    telesemana
    Participant

    @telesemana

    Apologies for the delay in responding and many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar