Skip Navigation

[Resolved] How to connect RFG to parent post with url parameter

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by puneetS-3 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1347805

I have a use case where, when someone fills up a post add-form, I want to send him an email with a link, where he can fill up the RFG to his post. Now earlier I had this problem, and it was sloved by Minesh, where he linked the child post to the logged in users post. Something like this,

add_action('cred_save_data', 'func_set_parent_to_rfg_entry', 5, 2);
function func_set_parent_to_rfg_entry($post_id, $form_data) {
    global $current_user;
    if ($form_data['id'] == 1515) {
       
         $args = array(
        'post_type'      => 'parent',
        'author'         => $current_user->ID,
        'status'         => 'publish',
        'posts_per_page' => 1
        );
                       $parent_post = get_posts( $args );
                     foreach($parent_post as $parent){
                              $parent_id = $parent->ID;
                            toolset_connect_posts('child', $parent_id, $post_id );
                      }
      }
}

I don't have any logins here, I just want to do it using a URL which I can share and then it gets connected to the concered parent identification of which can be done using the URL parameters. Can this be done.

#1347821

Hello,

I think it is possible, you just need to pass an URL parameter into the email link as HTML codes.

You can provide a test site with the same problem, also point out:
- Those two problem page URLs:
a) Where I can create the new post
b) Where I can create new item of repeatable field groups
- Those two form URLs

I can setup a demo for you.

#1347823

Private message box enabled.

#1347863
parent-wdl-id.JPG

Thanks for the details, I can log into your website, I have done below modifications in your website:
1) Edit the post form "wordpress service form":
- Add the relationship field "WordPress Web Development Lead" into the form content
It is required to put the relationship field into the child post form, see our document:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/front-end-forms-for-repeatable-field-groups/

- Option "Set default value from an URL parameter", fill a custom URL parameter name: parent-wdl-id, see screenshot parent-wdl-id.JPG
So it will be able to preset the default value of the relationship field by URL parameter, for example:
hidden link

Notice, you can use CSS codes to hide above relationship field, see our document:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected

2) Edit the post form "WordPress Lead Gen Fields", in section "Email to Lead", add below link in email body:

You can add more "Web Development Service" items here: <a href="[wpv-post-url item="34"]?parent-wdl-id=%%POST_ID%%">Add Web Development Service</a>

Number 34 is the page ID of "service-form-page"
Please test it again, check if it is what you want.

#1347909

This worked. Thanks a lot.