Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am creating a plugin that users can create forms with. Then the user will be able to input a shortcode to display this form. The shortcode will be the form name, which is stored as a meta_value in the wp_postmeta table. When the user uses a shortcode, how do I refer back to the form name & display the form?

When the user creates a form, should I automatically create a shortcode in the same script? How would you approach it?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You could use it like

[form id="abc123"]

where the value of id is the meta_value. You could generate the shortcode so the user can easily copy/paste it into the editor. Or even have a custom made button in the editor to insert it.

You can check how it's done in other plugins like Contact Form 7:

[contact-form-7 id="50" title="My form"]

http://wordpress.org/extend/plugins/contact-form-7/screenshots/

and Fast Secure Contact Form:

[si-contact-form form='1'] 

http://wordpress.org/extend/plugins/si-contact-form/screenshots/

share|improve this answer
    
Thanks for helping @birgire. I'm new to wordpress & worked this out when I turned my laptop off, so must be improving. Thanks again! –  mattnewbie Mar 12 '13 at 16:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.