Piklist has always been very powerful for building metaboxes and settings forms. For a long time, users in the official Piklist forum had been asking for the same form-building capabilities on the front end so that front-end forms could be created as easily as admin forms. That feature has finally arrived.
The way front-end forms are created is almost the same as in the WordPress admin area. The main difference is that on the front end you must define the scope parameter so the form knows where the submitted data should go. In the admin area, that part is detected automatically.
The steps for creating a front-end form are as follows:
- Create the form in code. See the post submission form and user profile form in the plugin demos for concrete examples.
- Add fields to the form, and make sure the
scopeparameter is set. - After adding the fields, add a submit button.
piklist('field', array(
'type' => 'submit'
,'field' => 'submit'
,'value' => '提交'
));
After the form is saved, Piklist automatically creates a shortcode for it. Insert that shortcode into a page and the form can be used on the front end.
If your form is created in a plugin, for example wp-content/plugins/my-plugin/parts/forms/my-form.php, you should use the following shortcode:
piklist_form form="my-form" add_on="my-plugin"
If your form is created in a theme, for example wp-content/themes/my-theme/piklist/parts/forms/my-form.php, you should use this shortcode instead:
piklist_form form="my-form" add_on="theme"
In the Piklist demos, the post submission form is located here:
/plugins/piklist/add-ons/piklist-demos/parts/forms/new-post-with-validation.php
With Piklist’s front-end form support, it becomes much easier to build front-end post submission forms, user profile editing forms, and similar workflows in WordPress.
