WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#4206 closed defect (bug) (fixed)

Publish button overrides Private post status

Reported by: mattyrob Owned by:
Milestone: 2.5 Priority: high
Severity: major Version: 2.1.3
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:
PR Number:

Description

When writing a new post, if a user sets the post status to "Private" and then clicks publish the post actually goes into the blog as a "Published" post, not a private one.

The code causing this (I think) is the wp_publish_post function in wp-includes/posts.php, it containes the following line:

return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true));

There are some if statements prior to this that check if the post is already published, perhaps a check could be put here to see if the post is private and a new line added as follows if this evaluates as true.

return wp_update_post(array('post_status' => 'private', 'ID' => $post_id, 'no_filter' => true));

This patch is untried!'''

Attachments (3)

4206.diff (883 bytes) - added by johnbillion 12 years ago.
Confirmation message when hitting the Publish button on a Private post (props andy)
4206b.diff (2.5 KB) - added by Nazgul 12 years ago.
private-post-notification.diff (2.8 KB) - added by JDTrower 12 years ago.
Warn users when editing a private post and click publish that continuing will result in the post being public.

Download all attachments as: .zip

Change History (22)

#1 @rob1n
12 years ago

  • Milestone changed from 2.1.4 to 2.2
  • Resolution set to fixed
  • Status changed from new to closed

#2 @rob1n
12 years ago

  • Milestone changed from 2.2 to 2.3

#3 @rob1n
12 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#4 @rob1n
12 years ago

  • Owner changed from anonymous to rob1n
  • Status changed from reopened to new

#5 @mattyrob
12 years ago

While we are doing this can there also be an action implemented for "publications" of private posts?

#6 @mattyrob
12 years ago

Finally got around to applying y suggested patch to the trunk files and it doesn't work :-( I guess there is more to it that I thought!

#7 @johnbillion
12 years ago

I thought that hitting the 'Publish' button and having the post status set to Published was the desired behaviour. I regularly write posts as drafts and then hit the publish button rather than changing the status to published then hitting save. If I was writing a private post I would set the status to Private and then click the Save button, not the Publish button.

#8 @andy
12 years ago

I thought implemented a nice feature to deal with this months ago but I guess I dreamed it.

"Publish" means publish no matter what the status is. When editing a Private post, if you click Publish IT WILL BE PUBLISHED. That's certainly better than saying "Publish means one thing here and another thing here."

The real problem is that people click "Publish" when they mean "Save" and they wish they hadn't. My solution is similar to what we do for the Delete button.

if (
    status == 'private' &&
    !confirm('This post is set to Private. Do you want to Publish this post for the world to see? (If not, try Save.)')
) return false;

#9 @mattyrob
12 years ago

It looks like some thoguht has already gone into this but never-the-less it is still confusing IMO.

As Andy says, the risk is users will click Publish when they should click Save to finish their Private posting.

I guess I'm saying "Publish" is like "Print"; while working on a document you may save it and then keep working for longer, or you may save and quit but when you are finished with it and you click print that's the end of the process - whether the document then remains private or goes for wider readship is up to your preferences.

I agree that clikcing Publish should change draft to published, but I don't think it should change the "Private" status of a post.

Perhaps the Publish button should have a drp down option to "Publish as Private" (just throwing ideas out)

#10 @foolswisdom
12 years ago

Andy's proposed solution seems like a very good immediate "work around".

@johnbillion
12 years ago

Confirmation message when hitting the Publish button on a Private post (props andy)

#11 @johnbillion
12 years ago

+1 for Andy's solution. Patch attached because I'm bored and needed to write some code.

#12 @mattyrob
12 years ago

+1 for this solution; a warning / reminder is better than nothing :-)

#13 @Nazgul
12 years ago

+1 to Andy's solution, -1 for current patch.

We should check the current setting of the checkbox, not the one at load time.

@Nazgul
12 years ago

#14 @Nazgul
12 years ago

  • Keywords has-patch added

Alternative patch uploaded which warns based on the current setting, not the on load setting.

#15 @lloydbudd
12 years ago

  • Priority changed from normal to high
  • Severity changed from normal to major

#16 @DD32
12 years ago

4206b.diff

To me that still doesnt help.

While i've never used a private post, my thoughts are that you'd "Publish it as a private post", The wording in the patch suggests to me that thats what happens, NOT that it'll be a published post rather than a private post.

#17 @rob1n
12 years ago

  • Owner rob1n deleted

@JDTrower
12 years ago

Warn users when editing a private post and click publish that continuing will result in the post being public.

#18 @JDTrower
12 years ago

  • Keywords needs-testing added

The attached patch private-post-notification.diff changes the wording from 4206b.diff.

The original wording from 4206.diff was:
"This post is set to Private. Are you sure you want to publish this post for the world to see? (If not, try the Save button.)

'OK' to continue, 'Cancel' to stop."

The original wording from 4206b.diff was:
"Are you sure you want to publish a private post?"

The current wording is:
"Are you sure you want your private post published for the world to see? (If not, try the Save button.)

Click OK to continue publishing or Cancel to stop."

I tested both 4206b.diff and private-post-notification.diff and they both work for me.

#19 @westi
12 years ago

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

(In [6872]) Make sure we can publish private posts. Fixes #5881, #4206.

Note: See TracTickets for help on using tickets.