reply-to-check.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. function ninja_forms_replyto_change() {
  3. $plugin_settings = nf_get_settings();
  4. if ( !isset ( $plugin_settings['fix_field_reply_to'] ) or $plugin_settings['fix_field_reply_to'] != 1 ) {
  5. $fields = ninja_forms_get_all_fields();
  6. foreach ($fields as $field) {
  7. if ( $field['type'] = '_text' ) {
  8. $change_required = false;
  9. if ( isset( $field['data']['from_email'] ) and $field['data']['from_email'] == 1 ) {
  10. $field['data']['replyto_email'] = 1;
  11. unset( $field['data']['from_email'] );
  12. $change_required = true;
  13. } elseif ( isset( $field['data']['from_email'] ) and $field['data']['from_email'] == 0 ) {
  14. $field['data']['replyto_email'] = 0;
  15. unset( $field['data']['from_email'] );
  16. $change_required = true;
  17. }
  18. if ( $change_required ) {
  19. $data = serialize( $field['data'] );
  20. $args = array(
  21. 'update_array' => array(
  22. 'data' => $data,
  23. ),
  24. 'where' => array(
  25. 'id' => $field['id'],
  26. ),
  27. );
  28. ninja_forms_update_field( $args );
  29. }
  30. }
  31. }
  32. $plugin_settings['fix_field_reply_to'] = 1;
  33. update_option( 'ninja_forms_settings', $plugin_settings );
  34. }
  35. }
  36. add_action( 'init', 'ninja_forms_replyto_change' );