WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 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:

Description

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)

comment:1 @johnbillion8 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?

comment:2 @johnbillion8 years ago

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

comment:3 @masquerade8 years ago

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

comment:4 @mattyrob8 years ago

Masquerade,

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 :-)

comment:5 @masquerade8 years ago

That is correct.

comment:6 @foolswisdom8 years ago

  • Milestone set to 2.4

comment:7 @mattyrob7 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

http://trac.wordpress.org/ticket/4620

comment:8 @foolswisdom7 years ago

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