You can achieve this using the save_post
hook, this is a hook that fires once a post has been saved. Below is an example addressing what you want to achieve:
function wpse253778_calculate_values( $post_id, $post ) {
if ( 'post' !== $post->post_type )
return;
$field = get_post_meta( $post_id, 'FIELD_NAME', true ); //get field value
$new_field_value="";//calculate new field value
update_post_meta( $post_id, 'NEW_FIELD', $new_field_value );
}
add_action( 'save_post', 'wpse253778_calculate_values', 10, 2 );
Related Posts:
- How to call a REST endpoint when a post is published?
- Access post meta just after publishing
- Returning ACF custom field from publish_post
- new_to_publish fires multiple times
- Post Meta Emtpy on Publish Using Transition
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- add_action hook for publish_post not working
- run script on publish
- post.php AJAX request not being called when publishing post
- Where is publish_post hook fired?
- WP-Automatic to run publish hooks
- Access post meta just after publishing
- disable publish button until condition is not met
- How to hook into publish_posttype?
- How to hook update_post_meta and delete_post_meta?
- Are there any hooks that alter the 404 logic?
- WooCommerce: change display order of product short description and price [closed]
- Is there a WordPress core & plugins update action hook?
- trigger save_post event programmatically
- Implementing advanced add_* function wrappers
- Hook into wp_head(); in a plugin
- is it possible to get the hook name in add_action?
- What hook is executed just after wp_query has been executed?
- How can I hook into the post editor title field in order to change the HTML?
- How to properly test a method that is called by an action hook
- How can I do customizations on login, registration and password recovery forms?
- WordPress v5.0.3 Gutenberg & JS error “Uncaught SyntaxError: missing ) after argument list”
- Custom form action hook
- How to send an automated user ‘inactivity’ email?
- wp_redirect() not working on form submission with init hook
- How do I successfully create a hook for an email override?
- Cast string to number
- How to debug user_register hook
- Storing state between hook functions
- What’s the difference between “wp” and “wp_loaded”?
- WordPress capabilities and restricted categories access
- How to use custom form on add_meta_boxes callback
- Is it possible to switch Gutenberg’s editor styles when document settings change?
- schedule event in class oriented plugin
- How can I find the hook I need to rewrite a function?
- Show message in media-new.php
- Hooks are not being removed in child theme
- Copy post to separate database with “add_action(….)”
- add_action second argument missing
- How to get user meta fields that have just been updated?
- admin_notices action doesn’t trigger within save_post action
- When a plugin gets updated from the repo, does the “activation” hook fire again?
- I don’t understand how add_action and do_action work in tandem. The former executes the code already…what is do_action for?
- Insert HTML in post, below nav bar but above content?
- Defining hooks within (php)classes?
- Divi hook not working [closed]
- Add WordPress hook outside of Plugin or Theme
- How to add content to suscriptor dashboard frontend?
- How to perform action when plugin/theme editor is used?
- How to run hooks one by one manually?
- What is the proper hook to use for recording a post view?
- How to load this code on function.php
- What hook should I use that will fire whenever I open a post for editing in the WP back-end?
- Woocommerce single_product_summary hook not working
- A good hook to check authorization and redirect?
- Is there a author_update action?
- Bloginfo hook – can it be more precise?
- Custom posts and get_post_meta in {$post_status}_{$post_type}
- Hooking custom PHP output into WP: how to do it, parse_request almost works but not quite
- Print on screen during shutdown hook – error during saving in theme-editor.php
- How to stop execution of a function via add_action hook?
- changing genesis_before_while in new theme framework
- Moving Javascript from footer to header
- Adding a new hidden field based on a condition in Ninja Forms
- Forcing WooCommerce customers to create account before checking out
- Store user ID on wp_term_taxonomy when new term inserted
- ‘user_register’ hook – need to distinguish if created from wp admin panel
- Make multiple URLs behave as home page
- remove_action not working for a function
- Update main post with same category when creating custom post to update the modified date
- Why isn’t update_post_meta saving?
- What hook should I use to add post meta data with on update?
- Transition_Post_Status hook not working properly
- Wodpress XML Import hooks
- profile_update hook does not fire from front-end
- wp_update_post not getting triggered by hook
- How to get user profile information before update?
- Why is pre_get_posts hook invoked multiple times?
- Undefined fieldId in gform.addFilter for limiting dates in datepicker – Gravity Forms
- Get First Post content and edit it using pre_get_posts (or similar?!)
- Are there Hooks for featured image popup?
- WordPress sending data with add_action
- How to hide / remove attachment “alt” or “caption” field in Admin?
- Exclude WooCommerce terminations from YOAST
- set_post_format called after wp_update_post when using bulk edit?
- Using actions, hooks and filters in a non-WordPress page
- Hook into create_category
- Trouble adding data to options table
- Change event firing in wordpress
- $GLOBALS & global doesn’t work [closed]
- Hooks not working on live server
- WP: Override/update the_content from database with the publicly echo the_content
- What is the equivalent hook for both admin_head() and wp_head() combined, if any?
- Search WordPress Hook for completed Elementor Update
- How to filter the URL of thumbnail size in the Media Grid and admin pages