• Resolved kkriss

    (@kkriss)


    Hello, nice plugin! Is it possible to map fields created with an Happy form to Advanced Custom Field custom fields, so that users can submit content directly to custom posts types? Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey there, @kkriss! ??

    HappyForms doesn’t include a way to do that through your interface, we’re sorry! It’s definitely possible though (and indeed quite easy) with a simple PHP hook and HappyForms submission callbacks. If you’re up for this small challenge, we’d be glad to share a practical snippet you can pop in your child theme functions.php file.

    Let us know what you think!

    Thread Starter kkriss

    (@kkriss)

    Hi. thanks for your reply. If you can suggest me how, I will try to do it but I can’t code at all, so please explain me step by step how to do it. After that, when I’ll have to map fields, will it be easy in a “visual” way? Thank you so much.

    Got it, @kkriss!

    We’re glad to share a simple snippet, but the actual implementation of the logic that follows depends on your plans, and we won’t be really able to help with every step of it. At no point along the path you’ll have visual controls available – let us know if this is a total showstopper for you.

    Here’s a super-basic example – accessing your submission data, and create a post with each form part mapped to a post meta field (notice that the wp_insert_post call intentionally misses some important data, like the post type):

    function child_theme_submission_success( $submission, $form, $message ) {
        wp_insert_post( array(
            'meta_input' => $submission
        ) );
    }
    
    add_action( 'happyforms_submission_success', 'child_theme_submission_success', 10, 3 );

    We hope that serves as a starting point! Let us know how you go.

    Thread Starter kkriss

    (@kkriss)

    Hi, thank you for the snippet, but I can’t complete it as I can’t code. Would you do that for me, considering a CPT called Books and CF such as Title, Description, Author? Is that enough? After having added this code to the child functions.php, the fields in the CPT will be automatically populated with no other actions? Thanks for your patience.

    Got it, @kkriss!

    As much as we’d like to help further with this, we don’t have a direct experience with ACF internals, we’re sorry!

    If you can get in touch with a developer to help you on this, the above snippet will probably be just enough for him/her to understand how to pull off this integration.

    Let us know what you think!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Mapping form fields’ is closed to new replies.