Actually WordPress offer a good hook , You can get data from Post Published , for more you can follow this example : https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
Example of a simple update of custom field:
/* Do something with the data entered */
add_action( 'save_post', 'myplugin_save_postdata' );
/* When the post is saved, saves our custom data */
function myplugin_save_postdata( $post_id ) {
// First we need to check if the current user is authorised to do this action.
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) )
return;
}
else {
if ( ! current_user_can( 'edit_post', $post_id ) )
return;
}
$mydata="something"; // Do something with $mydata
update_post_meta( $post_id, '_my_meta_value_key', $mydata );
}
Related Posts:
- Prevent publishing the post before setting a featured image?
- Add custom meta box on Post page
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Security checking in meta_box save is reluctant?
- WordPress metaboxes – textfield suggestion automatically populated
- Redirect to another page using contact form 7? [closed]
- Preset custom fields
- How to pass multiple custom fields as shortcode’s parameters
- Add custom field for users
- Add new post using a page inside the website
- Advanced Custom Field User Help URL
- How can i do custom author list?
- How to change data format in custom meta box field [closed]
- All of my custom posttypes are 404’ing
- Save / Show multi line text in metabox
- Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- PHP basics help in WP context – remove a class/function?
- auto populate list of questions if user select a category xyz
- is there a way to link one of the field in ACF field group, to a field in a media attachment page? [closed]
- How to toggle between two custom fields in WordPress woocommerce ‘WC Product Field Group’ plugin?
- Set featured image using javascript in post editor
- How to create an input field, and base the output on spreadsheet data? [closed]
- How to remove plugin metaboxes from edit.php
- How can I make my metabox appear?
- How do I hide posts across all loops based on the value of a custom field?
- How to inform the user that the save was not successful?
- Add padding while generating thumbnail
- Custom User meta field display
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- Execute js files doesn’t seem to work
- How to export all content with feature images?
- Char limit on custom blog-post form? [closed]
- Unable to select image using custom image field type
- Why are my queries interfering with the global post variable?
- Every new post/draft has a custom field variable “yst_is_cornerstone” showing
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- Custom Post Type Fields
- How do I enforce users to fill a determined custom field using WyPiekacz?
- Plugin to hide image in excerpt
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Cropping images from top center using Jetpack Photon
- Adding class to last list item? Not WP generated
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- Sticky option for custom post types without using custom fields or plugins
- Adding custom meta boxes to specified custom post type
- How do we update a custom file upload field with the Advanced Custom Field plugin?
- Order posts by meta key ( Using ACF )
- How to add fields in the WordPress editor?
- Access post title from custom meta box on title change
- Add “Featured Image” box in my plugin post page
- how to execute some code after a post is published in WordPress [duplicate]
- WordPress function to add text warning on every pages [closed]
- Couple of beginner’s questions [closed]
- Function added to hook “new_to_publish” not executing – custom plugin
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- trigger email when post is published by someone a user follows
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- Scrape a webpage for image and add it to post
- add_meta_box creating default form field types
- How to add an extra, independent set of custom fields?
- Should meta boxes for specific pages be save in their own plugins?
- Price comparison table based on Custom Post Type?
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- How can I store data from custom fields to custom tables?
- using add_action without having custom plugin or theme
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- WordPress meta-box and checkbox-list
- Adding featured image to posts created by a plugin
- Custom Fields for Page Edits
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- “After file loaded” action
- Add_image_size not generating correct size
- Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
- How to write a new file when new post has been published in WordPress
- Parent Child Custom Fields with Advanced Custom Fields
- grab or load text on demand
- How can I add user profile fields to my mailpress mailout
- Dictionary-style definition list plugin
- Advanced Custom Fields Plugin – Images not displaying
- Multiple Post Thumbnails Plugin – Need help with code
- Adding custom Field To The Posts Listing
- How to create repeater field manually, without plugin (ACF Pro)?
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- WordPress Phone Field Check (use numbers, spaces and pluses)
- What snippet do I need to type to show my ACF field show up on my theme?
- Can export gallery but can’t import it Wp all import
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Table of contents (TOC) plugin is not showing header tag
- Auto populate a user custom field from another user custom field
- Best approach to make all tags searchable by the wordpress search function
- Custom Meta box change size
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Create a pdf from the entries in DB