mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Merge pull request #790 from ultimatemember/fix/permanently_delete_fields
Permanently deleting form's field (issue #786)
This commit is contained in:
@@ -4,7 +4,7 @@ jQuery(document).ready(function() {
|
||||
jQuery(document.body).on('click', '.um-admin-btns a span.remove', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
if ( confirm( 'This will permanently delete this custom field from database' ) ) {
|
||||
if ( confirm( 'This will permanently delete this custom field from a database and from all forms on your site. Are you sure?' ) ) {
|
||||
|
||||
jQuery(this).parents('a').remove();
|
||||
|
||||
@@ -21,7 +21,7 @@ jQuery(document).ready(function() {
|
||||
|
||||
},
|
||||
success: function(data){
|
||||
|
||||
jQuery('#um-admin-form-builder .' + arg1).remove();
|
||||
},
|
||||
error: function(data){
|
||||
|
||||
|
||||
@@ -257,6 +257,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
update_option( 'um_fields', $fields );
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$forms = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'");
|
||||
foreach ( $forms as $form_id ) {
|
||||
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
||||
unset( $form_fields[ $id ] );
|
||||
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user