Fix Inconsistency of ID’s in PB v2

This function will fix inconsistency of ID’s in Profile Builder v2.

Make sure to:

  • run this only if you got problems after upgrading from PB v1.3 to PB v2
  • run it only once

init is located in wp-settings.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * Fix Inconsistency of ID's in PB v2.
 */
 
add_action( 'init', 'wppb_fix_manage_fields_id' );
function wppb_fix_manage_fields_id() {
   $manage_fields = get_option( 'wppb_manage_fields', false );
   if ( $manage_fields == false ) {
      return;
   }
   $i = 1;
   foreach( $manage_fields as $key => $field ) {
      $manage_fields[$key]['id'] = $i;
      $i++;
   }
   update_option( 'wppb_manage_fields', $manage_fields );
};