Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/post-template-condition-based-on-field
- // change the number 9 here to your form ID
- add_action('gform_post_submission_9', 'conditional_content_template_nine', 10, 2);
- function conditional_content_template_nine($entry, $form){
- // $post will contain the full WordPress Post that was created
- $post = get_post($entry['post_id']);
- // $entry[4] is equivalent to your Source field. Change the number to match your Source field
- // if $entry[4] is not empty, then change the post content
- if($entry[4] <> '') {
- $post->post_content = "$post->post_content <p>Source: <a href='$entry[4]' title='$post->post_title additional information'>$entry[4]</a></p><br class='clear' />";
- // be sure to save the updated post
- wp_update_post($post);
- }
- else { // clear the image with a br
- // I need to clear an image in my post whether or not there is a Source
- $post->post_content = "$post->post_content <br class='clear' />";
- wp_update_post($post);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement