0

I am using a frontend publish plugin that uses Wordpress's default publishing hooks to publish, and I am trying to create a function that will grab the data of one of the fields in the frontend form, and create a new meta field in the form with that data, plus an additional string of data.

I got everything to work properly but, only when updating the post does it wor. When I originally create the post, it just creates the meta filed, but the value is empty. Only when I update the post after it was published does it fill the meta field. I am thinking I need to pass the info to the function somehow, but I am unsure how to do that.

Here is what I have so far:

add_action('save_post', 'tree_price');

function tree_price( $post_id ) {
    $sale_price = get_post_meta( $post_id, 'rehub_offer_product_price', true );
    $tree_price = "sample text ".$sale_price;
    update_post_meta( $post_id, 'tree_price', $tree_price );
}

Any help is greatly appreciated! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.