• Resolved drharoonashraf

    (@drharoonashraf)


    I want to use a form to create posts from front end. I tried form to post with cf7. But in form to post one field can be identified as post title and another one as content. I want a 10 or more fields to be converted into post.
    Can it be done?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The code doesn’t currently support it. I supposed I should but in a hook where you can add your own code to consolidate different fields into the post content. LMK if you are interested.

    Thread Starter drharoonashraf

    (@drharoonashraf)

    I am not a programmer and I don’t know the codes. But I am willing to stretch myself if someone guides me. Please Simpson…

    Update to version 0.10 when it shows a available.

    You’ll need to install Add Shortcodes Actions And Filters plugin.

    You will need to modify the below example to suite your needs.

    Example: you don’t have a “post-content” or “post-title” field in your form, but you want to set those values as a combination of values from other form fields. In this simply example, our form has field “your-name” and “your-email”.

    The hook is used to create the “post-content” or “post-title” fields to be text with the value of fields “your-name” and “your-email” embedded in them.

    function f2p_consolidate_fields( $form_data ) { // change the function name as needed
        $form_title = 'F2P With Hook Example'; // Change this to your form name
        if ($form_data->title = $form_title) {
    
            // Next line sets the post_title value - change to match how you want the text
            $form_data->posted_data['post_title'] = "Post from {$form_data->posted_data['your-name']}";
    
            // Next line sets the post_content value - change to match how you want the text
            $form_data->posted_data['post_content'] =
                "This is a post from {$form_data->posted_data['your-name']} with email {$form_data->posted_data['your-email']}";
        }
        return $form_data;
    }
    add_filter( 'form_to_post_form_data', 'f2p_consolidate_fields', 10, 1 ); // make sure the function name matches above
    Thread Starter drharoonashraf

    (@drharoonashraf)

    Thanks,it works.. wonderfully…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Form to post’ is closed to new replies.