I have created a form which sends an email and creates a post.
I would then like to get the newly created post’s permalink and send with the email for the recipient to go see the post.
I was able to do this on your demo site, but now that i bought your product and installed on my live site, it does not work.
I have tried: Post Title
And
I have tried adding the following to the function.php in my child theme:
<?php
/**
* Gravity Wiz // Gravity Forms // Post Permalink Merge Tag
* http://gravitywiz.com
*/
class GWPostPermalink {
function __construct() {
add_filter('gform_custom_merge_tags', array($this, 'add_custom_merge_tag'), 10, 4);
add_filter('gform_replace_merge_tags', array($this, 'replace_merge_tag'), 10, 3);
}
function add_custom_merge_tag($merge_tags, $form_id, $fields, $element_id) {
if(!GFCommon::has_post_field($fields))
return $merge_tags;
$merge_tags[] = array('label' => 'Post Permalink', 'tag' => '{post_permalink}');
return $merge_tags;
}
function replace_merge_tag($text, $form, $entry) {
$custom_merge_tag = '{post_permalink}';
if(strpos($text, $custom_merge_tag) === false || !rgar($entry, 'post_id'))
return $text;
$post_permalink = get_permalink(rgar($entry, 'post_id'));
$text = str_replace($custom_merge_tag, $post_permalink, $text);
return $text;
}
}
new GWPostPermalink();
And then using: {Post Title:1}.
I can get the {post_permalink} to pop up the the merge tag list, but it does not return the url of the post.