Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4227 closed enhancement (fixed)

Add hook for first save as private post

Reported by: mattyrob Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.1.3
Component: General Keywords: hook
Focuses: Cc:


The are already a few hook in wp-includes/post.php relating to the editing, saving and publishig of posts but I think there is a gap.

I have a plugin (Subscribe2) that emails a list of subscribers when a post is made and several users have asked if I can add a feature to mail out when a private post is added.

By adding a hook that is called when a post is saved from Draft status to Private status for the first time, I could hook into this process to keep some of my users happy.

So, can a hook be added?

Change History (8)

#1 @johnbillion
11 years ago

  • Milestone 2.3 deleted

Mattyrob have you tried using an existing hook such as save_post and checking the value of the $post_status variable?

#2 @johnbillion
11 years ago

Oops, what I meant is comparing the value of $previous_status and $post_status.

#3 @masquerade
11 years ago

Scoping does not permit this. Think before you type, please.

#4 @mattyrob
11 years ago


I'm not 100% sure what "scoping" is, but am I right in thinking you are saying the JohnBillion's suggestion won't work?

Just checking before I spend time trying :-)

#5 @masquerade
11 years ago

That is correct.

#6 @foolswisdom
11 years ago

  • Milestone set to 2.4

#7 @mattyrob
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

The new wp_transition_post_status function takes care of this with the introduction of the new_to_private transition


#8 @foolswisdom
11 years ago

  • Milestone changed from 2.4 to 2.3
Note: See TracTickets for help on using tickets.