-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contact Form: Dynamic attributes lost when submitting form, when using do_shortcode #3187
Comments
@stdangerous -- To help cross-link everything, which pull request did you make months ago that went stale? I couldn't find one after a quick search. |
HI @kraftbj and @jeherve , I don't make many pull requests, so forgive me if I don't have the nomenclature correct, but my list of pull requests says #1 on Aug 10, 2015. - https://github.com/WebServicesManagement/jetpack/pulls Looking at it now, maybe that just went to my fork? Apologies for my lack of experience. |
@stdangerous GitHub's website for making edits and submitting PRs is really confusing. I've done that same thing before too. It did only get submitted to your fork, so we never saw it :-(. Thanks for your patience! |
@kraftbj Thanks for all the tireless work you guys put in! Any estimated timeline on 4.0? |
I created #3188 so we can test and discuss your changes. Thanks! |
I know there have been several other threads discussing this, but I can verify that trying to dynamically change the 'to' address of a Jetpack contact-form shortcode in a do_shortcode situation fails. The dynamic 'to' address isn't recognized. To repeat, try something like the following in your PHP:
echo do_shortcode( "[contact-form to='".$dynamic_user_email_addy."' subject='Custom Subject'][contact-field label='Your Name' type='name' required='1'/][/contact-form]" );
The custom 'to' attribute gets lost in the function process_form_submission. The shortcode is re-created, but the attributes don't come along with it.
I fixed the issue by
a) Saving the attributes via
update_post_meta()
in thestore_shortcode
function, like the shortcode content already is.b) Retrieving those attributes in the
process_form_submission
function usingget_post_meta()
, and then re-inserting the attributes into the shortcode just beforedo_shortcode()
is run again.I've tested my solution repeatedly and can verify it works. However, the whole process seems tortured. The do_shortcode function is being called twice. So while my 10 lines of code definitely fixes the surface problem, there might be a more elegant solution by simplifying the whole process. My fix feels like a band-aid, albeit a pretty good one.
I'm attaching my edited version. I made a pull request months ago, but nothing ever happened with it. However, I can make another pull request if it will help.
grunion-contact-form.php.zip
The text was updated successfully, but these errors were encountered: