Forum Replies Created

Viewing 3 Topics - 1 through 3 (of 3 total)
Author Posts
October 14, 2013 at 3:42 pm in reply to: Feeding variables into the custom forms? 8988
James James

Apologies for multi-post but I managed to get this to work with:

global $wp_query;
 $parentID = $wp_query->post->ID;

At the top of the function. Just leaving this here if anyone else needs it.

Thank you.

October 10, 2013 at 9:26 pm in reply to: Feeding variables into the custom forms? 8921
James James

Okay, so this is working fine but I am having trouble getting the parent post ID into the value of the input in the function.

Do you know how the best way to do this would be? Someone suggested putting $post->ID where the function is being called but I can’t find where the function is being called.

function chalet_review_id_hook($form_id, $post_id, $form_settings, $parentPostID) {
   global $parentPostID;
   $value = '';

   if ($post_id) {
      $value = get_post_meta($post_id, 'chalet_review_id', true);
   }
   ?>

   <div class="wpuf-label">
      <label>Hidden Chalet Review ID</label>
   </div>

   <div class="wpuf-fields">
      <input type="text" name="chalet_review_id" value="<?php echo esc_attr($parentPostID); ?>">
   </div>
   
   <?php
}

add_action('chalet_review_id', 'chalet_review_id_hook', 10, 3);

function update_my_brand_new_hook($post_id) {
   if (isset($_POST['chalet_review_id'])) {
      update_post_meta($post_id, 'chalet_review_id', $_POST['chalet_review_id']);
   }
}

add_action('wpuf_add_post_after_insert', 'update_my_brand_new_hook');
add_action('wpuf_edit_post_after_update', 'update_my_brand_new_hook');

The $parentPostID is the variable containing the parent post ID.

Thank you.

October 9, 2013 at 6:21 pm in reply to: Feeding variables into the custom forms? 8879
James James

Thank you so much for this!

Viewing 3 Topics - 1 through 3 (of 3 total)