• Resolved Rumi

    (@rumka)


    Hi!

    Right now Post Data has all the standard post fields like Title, Content, Featured Image etc. bundled together, with no separate settings for each filed. I’d like to have more granular control for what is required or not, display the fields in different order in my paginated form, and use all other forminator settings per field. So what I would love to do is use the forminator form fields and post them to the standard fields. Some examples:

    1. A simple textarea field, which I would set as required to post to the main post Content.

    2. A simple text area, not required, to post to the Excerpt

    3. A file upload, not required, to post to the Featured Image

    etc.

    I hope there is way to do this by posting each filed as custom filed, and then somehow set the correct “recipient” field value, but I don’t know what they are. I tried posting a text area to “post-body”, but this is not working. Is there a way to make this work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rumka

    I hope you are doing well.

    I’m afraid this isn’t possible at this moment, you can do work on this using custom code.

    When the form is submitted you can trigger this action:

    do_action( 'forminator_post_data_field_post_saved', $post_id, $field, $data, $this );

    This receives the Post ID and Fields data, which you can try to use your Post content, for example, create a regular text area for Excerpt, using the action and the wp_update_post();

    <?php
    
    add_action(forminator_post_data_field_post_saved, function($post_id, $field, $data){
        
    
      $the_post = array(
            'ID'           => $post_id, //the ID of the Post
            'post_excerpt' => $_POST['textarea-1'], //Text area content
        );
      wp_update_post( $the_post );
    
    }, 10, 3);

    https://developer.ww.wp.xz.cn/reference/functions/wp_update_post/
    https://stackoverflow.com/questions/17617858/wordpress-wp-insert-post-wp-update-post

    You can use the code as a mu-plugin following this guide:
    https://premium.wpmudev.org/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Let us know if you have any additional question on this.
    Best Regards
    Patrick Freitas

    Thread Starter Rumi

    (@rumka)

    Thank you, Patrick! I was hoping there is a way that doesn’t require custom code, but may need to try this if I cannot find another solution. I am still experimenting on how to achieve what I need, which is creating a new post from a form with a mix of standard and custom fields, and later on would need to allow users to edit already created posts. I am trying to avoid custom code for now, hoping I may find a plugin with more flexible posting functionality. I will try the above if I get stuck and need to rely on custom code anyway. Thank you so much for the example!

    Wish: I hope you guys will make the Post Data functionality more flexible in future. Would be awesome if standard post fields like title, content etc, can be easily mapped from Forminator fields, just the way custom fields are now. It will definitely make a lot of sense, and would be awesome.

    In any case I love Forminator, and thank you for the prompt response and help!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Post Data – Post Custom Fields to Standard Fields’ is closed to new replies.