When you create a new post, the initial post status is not new
, but rather auto-draft
. Try this:
add_action("draft_to_publish", "doSomething", 10,1);
function doSomething($post){
global $post;
$_SESSION['yeni'] = 'test';
}
echo $_SESSION['yeni'];
Also note that you may want to make sure your session is properly initialized. To verify the callback works at least, enable WP_DEBUG
and WP_DEBUG_LOG
and do something like
add_action("draft_to_publish", "doSomething", 10,1);
function doSomething($post){
error_log( 'Inside the new post transition');
}
Then publish a post and look at wp-content/debug.log
Related Posts:
- Visual Studio SignTool.exe Not Found
- How can I set a draft page as parent without publishing?
- Display a post’s publish date from 2112
- Does blocking xmlrpc.php affect pinging update services like pingomatic
- I can’t preview post’s change once they are published
- Publish post when edit post form submitted with enter/return pressed on keyboard
- How to make scheduled post preview visible to anyone?
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- Why does publish_{custom-post-type} fire on update?
- Show recent published posts
- Is there a way to know if a post has been published through XML-RPC?
- How to unpublish a page and still keep a draft?
- get_terms on save_post hook
- Save and Publish button not working after installing SSL
- Disable “preview changes” button
- Can we have private drafts?
- Update post meta on bulk edit / update
- Can’t schedule post for another time
- publish_post called too early
- Custom save button shows ‘Are you sure you want to…’ dialog
- Get publish post link?
- Controlled publishing in WordPress
- Change the text of the publish button to Save
- problem with publish date not always appearing [duplicate]
- What is happening to make my Update/Publish button disabled?
- After I publish a post where does it go
- Should you manually ping new WordPress posts?
- Authors should not publish
- How to add custom status to quick edit
- I need to modify drafts using custom data from database and then publish it
- How to show or hide a post based on meta_value selection?
- i am making text changes on my page show in preview not on live site, why? [closed]
- Is WordPress “publish” atomic?
- How to move post process to background
- How does redirect work when publish date changes and date in url changes?
- Gutenberg publish date datepicker
- How Google Indexer should only index published pages
- Publish and go to page [duplicate]
- Publish Post Action Not Working
- Is it normal for a scheduled post to say “Missed Schedule”
- Manage multiple wordpress installs (Best Practice)
- Showing the next post’s title, even if it’s an unpublished post
- Force Publish Future (Scheduled) Posts Immediately [duplicate]
- Can’t publish posts, Jetpack won’t connect, empty notification emails to my inbox [closed]
- Duplicate post on publish
- How is it possible to use a very reduced version of WordPress?
- Problems in updating a self-developed plugin
- How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
- Hide permalink and preview button and link on custom post
- How can I make it so the Add New Post page has Visibility set to Private by default?
- InDesign to WordPress workflow
- How can I make post fields required in WordPress?
- How can I add a jQuery OnClick event to the Publish posts button?
- Customize users’ capabilities to change a custom post’s post status
- How to limit user to publish post per day and per role?
- wp_login action hook not working
- Access post meta just after publishing
- Hiding by default specific post status on backend list?
- wp_publish_post breaks permalinks
- Detect Post Type when publish_post is ran
- Unpublish all posts in a category
- Posts created in a Custom Post Type are lost if published without a title
- publish_post conflicts with save_post
- How can I automatically set a post slug based on the post title during post publish?
- Error trying to publish immediately. Post status = future (Missed schedule error)
- Problem With Pages Displaying
- Print a message if excerpt is empty after posts have been publish/update!
- Check if checkbox is marked on publish/update post
- Set meta field to publish date + 2 weeks
- Publish Post when URL is available else reschedule the post in wordpress [duplicate]
- Redirect to page list when page published
- Published site reverts without changes to theme
- WordPress Front end Form – Enable to Submit PHP Codes
- wp_publish_post to saved draft, permalinks broken
- redirect deleted / drafted pages
- How can I move (or create another) publish button?
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- Send email when publish new post in certain categories
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- run script on publish
- Stop wordpress from creating empty/null entries
- How can I tell if a post has been published at least once?
- Send email for pending post
- using add_action without having custom plugin or theme
- Hook when post is set from published to draft?
- How to add published date in product [closed]
- How publish post from pending status
- ACF saving posts
- Do something with thumbnail image on post publish
- How can I add metaboxs to Admin Bar?
- Get content of publish box
- Publish post and create additional posts with same content
- I want to send push notification just after publish a new post
- disable publish button until condition is not met
- Updating User Meta from Custom Post Field Upon Publish Not Working
- Adding a Custom ‘Now’ button under ‘Published on’ header to return current date and time
- Tracing dashboard publish settings from input form in WordPress
- Plugin that generates a page of post content
- Default pages to be unpublished – possible?
- Emailing Authors only when a CUSTOM POST TYPE post is published- not when edited later [duplicate]