Is it possible to use URL Query Strings in Frontend Submissions to populate CFs?

Support MB Frontend Submission Is it possible to use URL Query Strings in Frontend Submissions to populate CFs?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33588
    esmroscesmrosc
    Participant

    I have used gravity forms and toolset forms in the past and found that the url query strings very useful for populating the custom fields for generating new CPTs. Is there any plan for a url query to be a part of Frontend Submission for the fields in the future or am I missing something that is already there?

    #33601
    GracesonGraceson
    Participant

    Note: I think of myself as an advanced googler rather than an actual dev. I'm also not familiar with the features in those other products mentioned, so my apologies if I have misunderstood what you want to do.

    However, I'm currently working on a project where I am saving custom info into hidden fields, which might be similar to what you want to do.

    Currently, I am making some hidden custom fields in MB. They don't show up in the frontend, but I can save whatever type of data I need to them by hooking into rwmb_frontend_after_process (currently I am using MB custom table to store everything). Then, it is just a matter of getting the data you want to save. I imagine that you can write some regex type code in some php functions to get strings out of the url to populate the fields. There might be more clever ways, but that is where stack overflow can come in handy.

    Hopefully that gives you a sense of one route to do this type of thing.

    #33618
    esmroscesmrosc
    Participant

    Thanks for your suggestion, I did not know about this so will look into it. I am already using rwmb_frontend_after_process to save some information into some custom fields so this could work well.

    #33627
    GracesonGraceson
    Participant

    Great! If you end up getting a working solution it might be nice to post some example code to help the next person who comes along.

    Also, in that vein, here is the link to the documentation for the hidden field type in case anyone needs it. I forgot to include it in my original response.

    https://docs.metabox.io/fields/hidden/.

    Here is a result I got for googling how to get strings out of URLs using PHP. Looks like there are a couple of helpful functions to do this sort of thing that can be put together. Depending on the info you are trying to collect, you may not even need Regex, which would be nice.

    https://stackoverflow.com/questions/13907793/preg-match-need-to-get-a-string-out-of-an-url

    In case you end up having to use Regex, here are some helpful cheat sheets for learning the syntax:

    https://www3.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html
    https://www.keycdn.com/support/regex-cheatsheet

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.