• Resolved tariquesani

    (@tariquesani)


    New to Pods, not new to wordpress or php.

    Am searching for some documentation on how to allow a logged in user to edit a pods CPT from the front end, preferably a free solution. Knowing how to do JS validation (in addition to server side validation) would be a bonus

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    <?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/

    Thread Starter tariquesani

    (@tariquesani)

    Thank you! That was helpful

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