Custom Fields
Support MB Relationships Auto Relationship on form submission

  • Creator
  • #31330
    Wojtek Piskorz

    Case study:

    CTA: Service
    CTA: Reviews

    Relationship between those 2.

    On single service template I have a form with: 1-5 rating, name, text content that creates a review post.

    Is it possible to setup the form to automatically create a relationship between review post that was created with a form submission and the single service that the form was submitted on this?

    And cherry on top: is it possible to use with fluent form integration 🙂 - I use FF integration for metabox submissions at the moment and I love it 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #31334
    Long Nguyen

    Hi Wojtek,

    Yes, it is possible to set the automatic relationship between the post submitted with the current page. Use this code to create a connection after submitting the form.

    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
        MB_Relationships_API::add( get_queried_object_id(), $post_id, 'your-relationship-ID', $order_from = 1, $order_to = 1 );
    }, 10, 2 );

    Refer to this topic

    Both Fluent Forms and MB Frontend Submission support submitting a post from frontend so I think you should use one.

    Wojtek Piskorz

    OK so here:

    I found an action that FF folks recommend to use if I want to execute any custom functionality.
    I'm trying to adjust the code you kindly provided and I just don't know how it's suppose to looks like.

    I also tried to exactly follow your loom tutorial (with use of MB forms) and it didnt work as well. Only difference I made was I used build-in relationship builder instead of coding it with codeblock.

    Sorry for being noob 🙁

    Long Nguyen


    Follow the FF documentation, you can try to use this code

    add_action('fluentform_before_submission_confirmation', 'your_custom_confirmation_function', 20, 3);
    function your_custom_confirmation_function( $entryId, $formData, $form )
       // Do your stuff here
        MB_Relationships_API::add( get_queried_object_id(), $entryId, 'your-relationship-ID', $order_from = 1, $order_to = 1 );

    to add the relationship between the post submitted via the form and the current page that shows the form.

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