Title: ¿Delete meta values in conditional fields?
Last modified: December 14, 2020

---

# ¿Delete meta values in conditional fields?

 *  Resolved [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * (@nchaccal)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/)
 * Hello!
 * I have some conditional fields in my profile and registration form.
 * For example, if I select “other” in a city field, another field will appear below
   to write the other city that does not appear in the selection field.
 * If the user decides to update their profile, changing their city for another,
   the text field of the other city will disappear, but the value of that field 
   will continue to exist in their usermeta profile.
 * In fact, if the user wants to show the “other field” again, the value will be
   there again.
 * Is there an easy way to remove meta values ​​in conditional fields?
 * I need this because these fields are then sent to a third party crm outside of
   WordPress.
 * Thank you 😉

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13790211)
 * Hi [@nchaccal](https://wordpress.org/support/users/nchaccal/)
 * You can use the following action hooks to modify the user details on User Registration
   and Profile Update:
 * `um_after_user_updated`
    $user_id, $args, $to_update’
 * `um_registration_set_extra_data`
    $user_id, $args
 * Regards,
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13795382)
 * Hey there!
 *  This thread has been inactive for a while so we’re going to go ahead and mark
   it Resolved.
 * Please feel free to re-open this thread by changing the Topic Status to ‘Not 
   Resolved’ if any other questions come up and we’d be happy to help. 🙂
 * Regards,
 *  Thread Starter [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * (@nchaccal)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13797495)
 * Hi!! Sorry for re-open again this thread.
 * I already did the function with your advice, but does not work with that hook.
   Maybe im doing something wrong?
 * My code works if i use the hook um_profile_content_main, but this clear the fields
   when user try to edit his profile.
 * I wanted to clear these fields after user edit his profile, but before send to
   DB.
 * I tried with um_user_before_updating_profile too. But nothing happen.
 * Any idea? BTW: I use the hook um_after_user_updated with another function already.
 *     ```
       function remove_before_send ($args) {
       	    ?>
               	<script>
       				var elements = document.querySelectorAll('.um-is-conditional');
       				for (var i = 0; i < elements.length; i++) {
           			elements[i].childNodes[1].childNodes[0].value = "PROBANDO";
       				}
              		</script>
           	<?php
       }
       add_action('um_profile_content_main', 'remove_before_send');
       ```
   
 *  Thread Starter [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * (@nchaccal)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13799215)
 * By the way. I’m still looking for a solution and found this thread which is exactly
   my problem:
 * [https://github.com/ultimatemember/ultimatemember/issues/381](https://github.com/ultimatemember/ultimatemember/issues/381)
 * Let me know if you could figure it out
 * Thanks!
 *  Thread Starter [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * (@nchaccal)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13800258)
 * Hi again!
 * I finally did it!
 * Im not proud, because i wanted to use php, but this is the best i could do:
 *     ```
       function remove_before_send () {
       ?>
        <script>
          var boton = document.querySelector("#input");
          boton.addEventListener("click", function(){
           var elements = document.querySelectorAll('.um-is-conditional');
            for (var i = 0; i < elements.length; i++) {
       	if (elements[i].style.display == "none") {
           	 elements[i].childNodes[1].childNodes[0].value = "";
       	}
             }
          });
        </script>
       <?php
       }
       add_filter( 'um_profile_content_main', 'remove_before_send');
       ```
   
    -  This reply was modified 5 years, 5 months ago by [Nicolas](https://wordpress.org/support/users/nchaccal/).
 *  Thread Starter [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * (@nchaccal)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13845972)
 * Hi, sorry for re-open this thread.
 * I want to know if the last update of the plugin which fixed conditional logic
   for the form fields without metakeys, solve this situation.
 * I would like to delete my custom code if the plugin do it by itself.
 * Thanks anyway and happy new year!!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘¿Delete meta values in conditional fields?’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Nicolas](https://wordpress.org/support/users/nchaccal/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/delete-meta-values-in-conditional-fields/#post-13845972)
 * Status: resolved