Created
December 2, 2024 12:44
-
-
Save yuriinalivaiko/2a473b4f09c12e103ca4597c298b1f5d to your computer and use it in GitHub Desktop.
Remove the glitch field from the Ultimate Member form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Set a field you want to remove here. | |
| $meta_key = 'um_number_graduation'; | |
| function um_delete_field( $meta_key ) { | |
| global $wpdb; | |
| // Remove the field. | |
| UM()->fields()->delete_field_from_db( $meta_key ); | |
| // Remove the field manually. | |
| $fields = get_option( 'um_fields', array() ); | |
| foreach ( $fields as $key => $field ) { | |
| if ( $key === $meta_key ) { | |
| do_action( 'um_delete_custom_field', $key, $field ); | |
| unset( $fields[ $key ] ); | |
| } | |
| } | |
| update_option( 'um_fields', $fields ); | |
| // Remove the field from forms manually. | |
| $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 ); | |
| if ( is_array( $form_fields ) ) { | |
| foreach ( $form_fields as $key => $field ) { | |
| if ( $key === $meta_key ) { | |
| do_action( 'um_delete_custom_field', $key, $field ); | |
| unset( $form_fields[ $key ] ); | |
| } | |
| } | |
| update_post_meta( $form_id, '_um_custom_fields', $form_fields ); | |
| } | |
| } | |
| } | |
| um_delete_field( $meta_key ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes the field is not deleted completely. This is a rare case. It may happen if the Internet connection is interrupted when the field is deleted.
Go to the profile form builder and click the plus (+) icon to open the "Fields Manager". Scroll down to see the "Custom Fields" section. Do you see the glitch field in this section? You can remove the field by clicking the cross (❌) icon, see image.
Image - Standard way to remove a field.

Try to remove the field using the code snippet from this gist if you don't see the glitch field in the "Custom Fields" section of the "Fields Manager".
You can use the Code Snippets plugin to execute this code, see image below. Change the
$meta_keyvariable to the Meta Key of the field you want to remove and click the "Execute Once" button.How to find the field Meta Key:
data-keyattribute of the field. The value inside thedata-keyattribute is the field Meta Key.Image - How to find the field Meta Key.

Image - How to execute the code.
