Hi
I have created a front end form which creates a new post (custom post type). I have also setup an automatic email to be sent out with the posts’ details. But I cannot figure out how to add the link in the email to the new post?
add_action('acf/save_post', 'my_save_post', 20);
function my_save_post($post_id) {
// Bail early if not a knowledgebase post
if( get_post_type($post_id) !== 'knowledgebase' ) {
return;
}
// Bail early if editing in admin
if( is_admin() ) {
return;
}
// Variables
$post = get_post($post_id);
// All my email content is in here, I've just left the link bit in.
$body .= '<a href="'.get_permalink().'">View and answer this question</a>';
// Send Email
wp_mail($to, $subject, $body, $headers );
}
get_permalink gets the previously added post. How do I get the post that is created?
Many Thanks
Solved!
get_permalink() should be get_permalink($post_id)