Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @egaldamez25

    How did you add the Hidden Input field? UM doesn’t have hidden fields as custom fields/predefined fields in the UM Form Builder. The custom code in the link only supports those custom fields in the Form Builder.

    Regards,

    Thread Starter egaldamez25

    (@egaldamez25)

    Hello, @champsupertramp thanks for your super fast reply I added a custom CSS class to a row in the form.
    meta_registration_data {
    display: none;
    }
    Just to hide it.

    But this is the field I’m trying to get from the query params.
    https://pasteboard.co/KjBrS0x.png

    Or maybe I’m getting it wrong haha do you mean the custom code only works with the predefined fields? or it can work with any custom one just using the meta?

    https://pasteboard.co/KjBtp9a.png

    Thank you!!

    • This reply was modified 4 years, 9 months ago by egaldamez25.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @egaldamez25

    Please try visibility:hidden instead of display:none.

    Regards,

    Thread Starter egaldamez25

    (@egaldamez25)

    Hello, @champsupertramp already tried that, I even moved the input from the hidden row, and tried to use the first name default field like the example in the URL above.
    Is possible that this has something to do with the URL I have the registration form?
    mydomain/log-and-register/#/select-plan/business-account/plan2/form-page/?plan=plan2

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @egaldamez25

    Have you tried this URL?

    mydomain/log-and-register/?plan=plan2#/select-plan/business-account/plan2/form-page/

    Regards,

    Thread Starter egaldamez25

    (@egaldamez25)

    Yes already tried that, seems like it only works on the default route and default register page.
    mydomain/register/[email protected]&first_name=champ&last_name=camba

    But it doesn’t work on a custom form created in UM.

    Thanks anyway Champ!!

    Thread Starter egaldamez25

    (@egaldamez25)

    @champsupertramp Just in case anyone else has the same need i got it working removing the
    && function_exists("um_is_core_page") && um_is_core_page("register")

    from the function in the URL above.

    So I have this on my function file.

    add_filter("um_field_value","um_custom_register_clear_value",10 ,5 );
    function um_custom_register_clear_value( $value, $default, $key, $type, $data  ){
        
    	if( isset( $_REQUEST[ $key ] ) ){
    		return esc_attr( $_REQUEST[ $key ] );
    	}
        return $value;
    }
    

    Thank you Champ 🙂

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @egaldamez25

    Okay, so you’ve added the UM Register form to a non-UM page.

    I created this solution when you have hash routes to the URL, you can use this script to populate the hidden field:

    
    jQuery(document).ready(function() {
       function um_getQueryParams(qs) {
          qs = qs.split("+").join(" ");
    
          var params = {},
             tokens,
             re = /[?&]?([^=]+)=([^&]*)/g;
    
          while ((tokens = re.exec(qs))) {
             params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
          }
    
          return params;
       }
    
       if (window.location.href.indexOf("?") != -1) {
          var uri = window.location.href.split("?");
          var data = um_getQueryParams(uri[1]);
          jQuery("div[data-key='plan']")
             .find("input")
             .attr("value", data.plan);
       }
    });

    Sample URL:
    http://um2021.local/register/#/select-plan/business-account/plan2/form-page/?plan=plan-premium

    Regards,

    Thread Starter egaldamez25

    (@egaldamez25)

    Thank you again @champsupertramp that worked.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Thanks for letting us know.

    Regards,

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

The topic ‘Query Parameters on Hidden Input’ is closed to new replies.