XF 2 I need help to merge some custom user fields (values)

Scandal

Active member
First of all I want to notice that I'm a xF2 developer too, so I'm very okay to contact with other developers in "our language" and I know clearly what I need :). I'm doing some rehearsals of merging two of my own xF2 sites, and I have to merge also some (very) common custom user fields and I need help with it so I can save time.

Here is my plan. Budget $50 via PayPal.
  • I don't need an addon. I need just a php part of code (in xF2 standards) so I can place it on an Admin Controller to be run only once (or in batches, I will see it by myself).
  • We had two xF2 sites that are merged now (rehearsal) and both sites' xf_user_field and xf_user_field_value have the data on the final board (db).
  • The problem: I need to merge the xf_user_field_value(s) of the following xf_user_field(s). It is easy to merge text fields via a script, but fields with default choices have problem as you can see.

Below are the field_id(s). All are on the same db (final board):
PHP:
        // source => target
        $field_ids = array(
            'flo' => 'f_lo',
            'agapim_na_e_di_moysik_s' => 'agapimna_edi_moysiks',
            'epggelma' => 'ep_ggelma',
            'perioch' => 't_pos_diamon_s',
            'genik_endiafronta' => 'genik_endiaf_ronta',
            'politikooikonomiks' => 'politikooikonomik_s',
            'spoyds' => 'spoyd_s_panepist_mio',
            'agapimna_edi_vivlon' => 'agapim_na_e_di_vivl_on',
            'thriskeytiks_pepoithseis' => 'thriskeytik_s_pepoith_sei',
            'spoyd_s_2' => 'spoyds_2',
            'agapimna_edi_tainin' => 'agapim_na_e_di_taini_n',
            'toma_poy_me_empn_oyn' => 'toma_poy_me_empnoyn',
            'iek_eidik_tita' => 'iek_eidiktita',
            'ex_mino_spoyd_n' => 'exmino_spoydn',
            'metaptychiak_s_spoyd_s' => 'metaptychiaks_spoyds',
            'x_nes_gl_sses_ep_pedo' => 'xnes_glsses_eppedo',
            'poio_e_nai_to_m_to_soy' => 'poio_enai_to_mto_soy',
            'athlitik_om_da' => 'athlitik_omda',
            'to_aytok_nito_i_michan' => 'to_aytoknito_i_michan',
            'agapim_ni_p_li_chori' => 'agapimni_pli_chori',
            'poia_e_nai_ta_agapim_na' => 'poia_enai_ta_agapimna_2',
            'agapim_na_vinteopaichn_di' => 'agapimna_vinteopaichndia',
            'idi_tita' => 'iditita',
        );
  • But: some of them which have default selection choices for the user, they have the same Text [Options for choice fields] but different Value (so the xf_user_field_value -> field_value cannot be the same between the above pairs).
  • So we need to parse all field_values of [source] fields, to check if there is match with [target] by field Text and then save it correctly (fill the field for user X). If the field is text box, then save it "as is".
  • Notice 1: some [source] -> [target] pairs have different field_type as following:
- Text boxes are always text boxes.
- Multiple selection Checkboxes are always multiple selection checkboxes.
- In some cases a drop down selection (single choice) could be radio buttons (single choice). But still with different Value (but same Text).
- Examples:
userfield1.png
userfield2.png
  • I don't need to change any xf_user_field field_choices of any field definition. Only if there is match with existing field_choices of [target] the field value (array item) will be saved. On the example screenshots, Jazz and Τζαζ pair choice should be ignored since it is not the same (language / cannot be compared).
  • For confirmation reasons is not necessary your script to delete at the end the source fields. I will do it manually at the end via my AdminCP when be sure that user profiles have really the correct data.
  • Let me know if you're interesting to undertake this project and if you have any question. The budget is firmly $50, just to provide me this php code.
  • The code should meet all xF2 standards (entities/ finders etc).
  • Project will be started on the next week.
Thank you very much!!
Regards!
P.
 
Top