<?php
// @see https://docs.pods.io/code/pods/form/
if ( is_user_logged_in() ) {
echo pods( 'post', get_the_ID() )->form(
[
'post_title',
'post_content',
'_thumbnail_id',
'field_name_1',
],
'Save'
);
}
…where the post type is post
and get_the_ID()
returns the ID of the post if the code is run on that post’s singular template, for example using the_content
filter to add the form to the end of post content (returning content with form appended, rather than echo-ing).
Validation is more complex. Field input will be sanitized according to allowed data types, but setting a field to required in some contexts gives an error one field at a time, in other contexts (Block Editor), may not save and not give a message.
The most thorough validation feedback, having more to do with user feedback than security, is to show feedback as users fill out the form, showing/hiding the submit button if necessary. Custom validation can be done with JavaScript on input
or change
events or within setInterval()
by checking field values using https://docs.pods.io/code/dfv-js-api/
Also see https://www.ads-software.com/plugins/wp-user-frontend/