Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/if-statement-in-content-template
- // conditionally modify the post body if there is a document uploaded or a URL submitted
- // if there is a document uploaded in $entry[6], then link to it with the text "Additional Information"
- // if there is a URL submitted in $entry[5], then link the text to the external website
- add_action('gform_after_submission_1', 'conditional_content_template_one', 10, 2);
- function conditional_content_template_one($entry, $form){
- $post = get_post($entry['post_id']);
- // if either field 6 or field 5 has a value, then add the "additional information" header
- if(($entry[6]) <> '' || ($entry[5] <> '')) {
- $post->post_content = "$post->post_content\n<h4>Additional Information</h4> ";
- // field 6 == document upload
- if($entry[6] <> '') {
- $post->post_content = "$post->post_content\n<a href='$entry[6]' title='Additional documentation for $entry[1]'>Uploaded documentation</a><br class='clear' />";
- }
- // field 5 == URL
- if($entry[5] <> '') {
- $post->post_content = "$post->post_content\n<a target='_blank' href='$entry[5]' title='Visit external website for $entry[1]'>$entry[5]</a><br class='clear' />";
- }
- wp_update_post($post);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement