• Resolved Nicolas

    (@nchaccal)


    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

    (@champsupertramp)

    Hi @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

    (@champsupertramp)

    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

    (@nchaccal)

    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

    (@nchaccal)

    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

    Let me know if you could figure it out

    Thanks!

    Thread Starter Nicolas

    (@nchaccal)

    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 3 years, 9 months ago by Nicolas.
    Thread Starter Nicolas

    (@nchaccal)

    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.