Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Insert the post ID into a custom field after the entry and post are created
- // Help Scout 29933
- // References:
- // http://www.gravityhelp.com/documentation/page/Gform_after_submission
- // http://codex.wordpress.org/Function_Reference/get_post_meta
- // http://php.net/manual/en/function.str-replace.php
- // http://codex.wordpress.org/Function_Reference/update_post_meta
- // change the 411 here to your form ID
- add_action('gform_after_submission_411', 'update_custom_field', 10, 2);
- function update_custom_field($entry, $form) {
- // the post ID of the recently created post
- $pid = $entry['post_id'];
- // the meta key for the custom field we want to update
- $key = 'portfolio_item_description';
- // the placeholder text we are searching for
- $needle = 'PORTFOLIOPOSTID';
- // the content we are going to search within
- $haystack = get_post_meta($pid, $key, TRUE);
- // the modified content
- $new_description = str_replace($needle, $pid, $haystack);
- // insert the modified content back in the custom field
- update_post_meta($pid, $key, $new_description);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement