Advertisement
Guest User

Untitled

a guest
Dec 5th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function render_posttitle( $form_id, $post_id, $form_settings ) {
  2. $value = get_post_field( $post_id, 'post_title', true );
  3. if ( $post_id ) {
  4. $value = get_post_meta( $post_id, 'meta_posttitle', true );
  5. }
  6. ?>
  7. <div class="wpuf-label">
  8. <label>A demo field</label>
  9. </div>
  10. <div class="wpuf-fields">
  11. <input type="text" name="my_custom_field" value="<?php echo esc_attr( $value ); ?>">
  12. </div>
  13. <?php
  14. }
  15. add_action( 'hook_posttitle', 'render_posttitle', 10, 3 );
  16.  
  17. /**
  18. * Update the custom field when the form submits
  19. *
  20. * @param type $post_id
  21. */
  22. function update_hook_posttitle( $post_id ) {
  23. if ( isset( $_POST['my_custom_field'] ) ) {
  24. update_post_meta( $post_id, 'meta_posttitle', $_POST['my_custom_field'] );
  25. }
  26. }
  27.  
  28. add_action( 'wpuf_add_post_after_insert', 'update_hook_posttitle' );
  29. add_action( 'wpuf_edit_post_after_update', 'update_hook_posttitle' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement