Everything worked fine until had to have payment option using Toolset Forms Commerce. User is being created but not the post after the payment has been done and the order is marked completed. I am using the following code
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
if ($form_data['id']==225)
{
$my_post = array(
'post_title' => $_POST['wpcf-user-company-name'],
'post_status' => 'draft',
'post_author' => $post_id,
'post_type' => 'company'
);
// Insert the post into the database
wp_insert_post( $my_post );
}
}
I tried "cred_before_save_data" , "cred_submit_complete" and "cred_submit_complete" too in place of "cred_save_data" still didnt work. How do I get it work with payments?
It seems as though none of the cred commerce hooks are working. What I would like to do is to test this on my local environment and see if the same issue occurs.
Would you mind if I took one of the duplicator packages for testing ?
The hook actually works 🙂 the problem was that the wrong ID was being used on the hook for the form. In the hook ID 225 was being used when it should've been 675.
Oh yes you are right Shane, that was so dumb mistake on my side. I should have updated the id when I created a new form to test.
But, there is an issue. New post is bring created but with no title and no author! The new user created should have been author and the company name from the form should have been the post title.