Tell us what you are trying to do?
I'm trying to re-create an action that was happening on a previous instance of my site that didn't use Toolset, but make it work with the plugin. Basically, I have a custom post type "members", and i'd like to automatically create a post and fill out the custom fields whenever somebody fills in a gravity form to 'apply for membership', which then uses the details in that form to fill out the custom fields and post title.
In the previous instance, the code worked like this:
add_action('gform_after_submission_16', 'create_drafted_member', 10, 2);
function create_drafted_member($entry, $form) {
$member = [
'post_title' => $entry["62"] . ' ' . $entry["13"] . ' ' . $entry["11"],
'post_status' => 'draft',
'post_type' => 'member',
'comment_status' => 'closed',
];
$member_meta = [
'_member_details_title' => $entry["62"],
'_member_details_first_name' => $entry["13"],
'_member_details_surname' => $entry["11"],
'_member_details_nickname' => $entry["12"],
'_member_details_id_number' => $entry["14"],
'_member_details_nationality' => $entry["16"],
'_contact_details_email' => $entry["24"],
'_contact_details_mobile' => $entry["23"],
'_contact_details_telephone' => $entry["20"],
'_contact_details_telephone_home' => $entry["21"],
'_contact_details_fax' => $entry["22"],
'_contact_details_website' => $entry["25"],
'_contact_details_physical_address' => $entry["36"],
'_contact_details_postal_address' => $entry["41"],
];
// Insert the post into the database
$post_id = wp_insert_post($member);
foreach ($member_meta as $meta_key => $meta_value) {
update_post_meta($post_id, $meta_key, $meta_value);
}
}
Would this same function work with Toolset by just replacing the fields like '_member_details_title' with the slugs i have set up in Toolset? Also, the one other function i need to add to make it so that it works with an existing view query is to edit it so that the Post Author is set as the currently logged in user for the newly-created post, is that possible?
If you need any more information please let me know.