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.
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.
Private message box enabled.
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.
This worked. Thanks a lot.