Support

Account

Home Forums General Issues Recoding a User Field to a new one Reply To: Recoding a User Field to a new one

  • If you want another field, yes this is possible.

    Basically you would create the new field. Then you would create an acf/save_post filter that will get the value from your new field and update the correct value for the other plugin. The exact details of doing this are highly dependent on the other plugin https://www.advancedcustomfields.com/resources/acf-save_post/

    You could use a select field for this, or a radio field.

    A basic example

    
    add_filter('acf/save_post', 'my_acf_update_user_field', 20, 1);
    function my_acf_update_user_field($post_id) {
      if (substr($post_id, 0, 5) != 'user_') {
        // not a user being updated
        return;
      }
      // get user ID from $post_id
      $user_id = intval(substr($post_id, 5));
      // get value of your field
      $value = get_field('your-field-name', $post_id);
      // do whatever needs to be done to update the field for other plugin
    }