Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function render_posttitle( $form_id, $post_id, $form_settings ) {
- $value = get_post_field( $post_id, 'post_title', true );
- if ( $post_id ) {
- $value = get_post_meta( $post_id, 'meta_posttitle', true );
- }
- ?>
- <div class="wpuf-label">
- <label>A demo field</label>
- </div>
- <div class="wpuf-fields">
- <input type="text" name="my_custom_field" value="<?php echo esc_attr( $value ); ?>">
- </div>
- <?php
- }
- add_action( 'hook_posttitle', 'render_posttitle', 10, 3 );
- /**
- * Update the custom field when the form submits
- *
- * @param type $post_id
- */
- function update_hook_posttitle( $post_id ) {
- if ( isset( $_POST['my_custom_field'] ) ) {
- update_post_meta( $post_id, 'meta_posttitle', $_POST['my_custom_field'] );
- }
- }
- add_action( 'wpuf_add_post_after_insert', 'update_hook_posttitle' );
- add_action( 'wpuf_edit_post_after_update', 'update_hook_posttitle' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement