I want CRED to generate a notification email to the email address of the author of a parent CPT ("company -profile") when a CRED form creating a related child post is submitted.
I found a relevant similar query in Paid support - https://toolset.com/forums/topic/send-cred-notification-to-parent-custom-email-field/. That query related to sending an email to an address specified in a field in the parent CPT). I cannot figure out how to apply that answer to my situation. What I want is to notify the author of the parent post...
Thanks Minesh, I had read the post you referred me to but my situation is different. I am wanting to pick up the email of the author rather than an email specified in a custom field of the parent CPT.
I am also a little less proficient at programming than the last person you helped so could you please be more specific about what I should do?
The result I got was
-the option to send a notification to email specified in a form field
-the Username of the Author of the parent post was displayed on the CRED form
But not email was received by the Post Author.
Could you please advise how to fix this code so that notifications are sent to the author of the Parent post AND neither the author's username or email address appears in the CRED from.
Could you please send me link of the page where you've added CRED form.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
hidden link
I go to this company profile and added my email address to email address field - correct?
Now, I've added info about problem solver form and now I'm on connection form:
=> hidden link
On above form I can see that we can select company profiles from dorp-down box, you mean to say now if I select "wptypes-test" drom company profiles drop-down and submit the form you want to send email to email address which I've added to "wptypes-test" profile?
And correct to your second Question. What I want to achieve is that when you may a connection to WP types a notification is sent to you as author of the WP Types Company profile so that you know you have a pending request to moderate.
Then I've catch the field assigned company profile email using following code that is added to your current theme's functions.php file.
add_action('cred_before_save_data', 'my_before_save_data_action',10,1);
function my_before_save_data_action($form_data)
{
// if a specific form
if ($form_data['id']==5493)
{
if(isset($_POST['_wpcf_belongs_company-profile_id']) and $_POST['_wpcf_belongs_company-profile_id']!=""){
$parent_post_id = $_POST['_wpcf_belongs_company-profile_id'];
$x = get_post_meta($parent_post_id,'wpcf-email-address',true);
$_POST['parent-notification-email'] = $x;
}
}
}
To test this you should again change email address from "wptypes Test" company to your email then you will receive notification and I hope your issue is resolved here as well as your another issue that was with me that also resolved here.
Thank you for your efforts. But I am afraid what you have done doesn't work as required... I need an email to go to the email address of the Author of the Company Profile Parent. On reflection I wasn't sufficiently clear with my last response I am sorry...I should have asked you to add your email address to your the WP Types User, rather than the email field in the Company profile... Which I have now done for you. Hopefully it is not too much work to make it work as I hope it can.
I have just been transferring this to my live site and have noticed that although it all works... the CRED plugin does not appear to recoginse the notification as being set up correctly... the notification was set to the checkbox for " Send notification to a specific email address:" and works.. but doesn't look like it is set up properly and generates alerts within the CRED Edit page when it is saved... see the attached screenshot.
I wonder how hard it would be to adjust the solution you developed to appear to be completed properly such as by coming up as an option to select under the checkbox for "Send notification to an email specified in a form field:"?
Cheers
Peter
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.