Try to use the post object provided by the action as the second parameter instead of getting it from database:
function change_event_slug_on_save( $post_id, $post ) {
...
}
add_action( 'save_post', 'change_event_slug_on_save', 10, 2 );
With this you can remove the line $post = get_post($post_id);
EDIT:
Tribe Events Calendar has it’s own actions for saving an event: tribe_events_event_save
and tribe_events_update_meta
. Since the event date is saved in post_meta you should use the second action:
/**
* @param int $event_id The event ID (alias post ID).
* @param array $data The saved meta fields. The new date should be somewhere in this array
* @param WP_Post $event The event itself (alias $post).
*/
function change_event_slug_on_save($event_id, $data, $event) {
...
}
add_action('tribe_events_update_meta', 'change_event_slug_on_save', 10, 3);
Related Posts:
- How to hook into permalink when publishing-saving post?
- How to filter to output of the get_permalink() function
- ‘post_type_link’ filter not working
- Is there an action for when permalinks are rebuilt?
- WP JSON list all permalinks
- How to get url of a post from admin panel
- Filtering comment permalinks when a condition is met
- What is the action or filter for changing permalink in Edit Post/Page?
- Remove the Parent category from the permalink but leave the child category
- Multilanguage URLs
- Change permalink structure hidden button edit
- How to change the permalink option to post name on theme activation?
- is there a way to add the post URL to the results of fselect facet in Facetwp plugin?
- Edit page slug after save, cause 404 by linked pages
- Process all virtual sub pages on parent page
- rewrite rule to redirect to the most recent date permalink
- Permalink slug no longer editable when using post_type_link filter
- WordPress Permalink feature alternative
- Inserting a string in the middle of page’s permalink?
- Access or edit custom generated permalinks with WP_Rewrite
- Custom child page permalink
- Modify post slug before saving
- Remove character from permalink
- Edit the output of a filter
- Fire a code when permalinks updated
- Edit Post Permalink option removed, looking for possible causes
- I can get the permalink or the excerpt to work correctly, but not both
- Search and replace post URL’s on page output?
- Custom Permalinks and filters?
- Once redirected by Rewrite rules, how can WordPress know the page?
- Change permalink when page category selected in admin
- How to update permalink on the fly?
- Getting the terms from “Beautiful Taxonomy Filters” Results ot Integrate into “Ajax Load More”
- Set new url from custom post field
- Rewrite permalink with PHP processing
- Is there a way to auto-link to products when writing a post?
- rewrite based slug standar post wp
- A dash can replace a period in a link, how to fix it
- Variation prices breakdown only for single product page
- How to update wordpress permalink structure with author role?
- How to turn a custom query string into permalink?
- WordPress wildcard route to page
- Undefined variable: testimonial in D:\Projects\PWP-WP\wp-content\themes\blankslate-child\template-parts\fields\flex\bottom-page-block.php on line 123
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Is it possible to set public to false for the native WordPress blog
- Best way to fix bad count on All | Mine | Published
- WP Multisite Subdirectory Custom Permalinks 404
- How can i fix my permalinks?
- How to add custom media library mime icons?
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- WordPress’ «post name» setting broken
- Adding custom query var to a single post without redirecting to its root slug
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- Read more block is appending /#more-{post_id} to the link
- Filter the title to only affect the_title() template function
- Permalink refresh, the good, the bad, etc. What is best?
- URL getting changed
- Remove and replace woocommerce add to cart button [closed]
- Keep wordpress basic permalink preferences
- Woocommerce : Add name filed of checkout page to buyers wordpress display name
- How to change specific permalink in wordpress site?
- style_loader_tag not changing stylesheet to preload
- Create different permalinks for same post
- index.php in URL
- assets aren’t loading on a page but loads on others? slug permalink conflict?
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- remove SLASH on single_post but KEEP on categories and parent pages
- How to prevent wordpress from lowering Capitalized letters
- archive by year and category: permalink support doesn’t work on pagination
- Adding a ‘blogs’ prefix in the URL structure but only for blogs
- Restricting displayed posts to posts from only select authors
- An excluded ‘ghost’ page is crashing my permalink
- WordPress permalink not working on subdomain
- Whole site’s pagination not working after rewriting product permalink
- Load-balanced site frequently losing permalink settings
- Unpublished Pages Failing To Appear On Custom Path
- Convert $ _GET to permalink
- WordPress Attachment Page URL Rewrite!
- Customize URL for specific tags archive
- Permalink blog page (only) not working
- Problems fixing a REST API 404 after Moving my WordPress Directory and updating Permalink Structure
- Xampp 7.3.3 fresh install of WordPress 404 pages unless permalink is set to plain
- Randomize post (and page) IDs on generation
- Hook to change the site URL
- Make the blog page a child of another page and rewrite the blog url
- WordPress slug confusion
- Link to a page before launch
- where can i see wordpress automatic redirect History
- I use wordpress wp-page navi
- Multiple Taxonomy Items for Separate URLs
- How to get title of images in post content
- WordPress keeps removing query var from the URL
- Limit get_next_post to posts from the same author
- MySQL-inserted custom taxonomy term lead to 404, flush rewrites doesn’t help
- .htaccess to redirect to a wp page
- Empty the_excerpt() broke the_permalink() under him?
- URL gives 404 error of my subfolder site when i change permalink
- Store a value in global scope after init hook is fired
- Homepage template and url changed?
- Fatal Error when trying to load Permalinks page on WP admin [closed]