Home Forums ACF PRO Front End Form & Permalinks


Front End Form & Permalinks

  • 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' ) {		
    	// Bail early if editing in admin
    	if( is_admin() ) {		
    	// 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)

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Front End Form & Permalinks’ is closed to new replies.