Send comment notification to custom email from a meta value
-
I have been trying for days to get wp comments to notify a custom email when a comment is made. I finally got it to work when I type the email address into the wp_mail function. like so.
add_filter("comment_post", "email_project_designer"); function email_project_designer(){ wp_mail( '[email protected]' , 'subject', 'message' ); }
That works great. But I really need the email address to be populated using a custom meta value from the post that is receiving the new comment. The code below is as far as I got, with no luck. My feeling is the action has no idea what post to associate the function with.
If it makes a difference, This function is being included with a plugin that uses custom post types. The meta value comes from the custom post type included with the plugin.
add_filter("comment_post", "email_project_designer"); function email_project_designer(){ $p_designer_email = get_post_meta( $post->id, 'project_designer_email', true ); wp_mail( $p_designer_email , 'subject', 'message' ); }
Thanks in advance for any help.
Ray
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Send comment notification to custom email from a meta value’ is closed to new replies.