Make WordPress Core

Opened 16 years ago

Closed 10 years ago

Last modified 9 years ago

#6939 closed enhancement (duplicate)

wp_list_pages() should also lists private pages if the user has capability 'read_private_pages'

Reported by: imwebgefunden's profile imwebgefunden Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.1
Component: Template Keywords: has-patch featured gsoc needs-testing
Focuses: Cc:


If the user has the capability "read_private_pages" wp_list_pages() don't lists private pages in no way. I've noticed this problem by some comments on my "Role Manager" Plugin page.

Two patches are attached to this ticket.

wp_list_pages() gets a new option "include_private_pages". The default value is 1 for lists private pages too if the user has the capability "read_private_pages".
If private pages should not be listed also if the user has the cap "read_private_pages" the syntax is as an example:

The second patch is for get_pages() - with the same option and default value.

And of course: if a user don't has the cap "read_private_pages" private pages are listed in no case :)

Attachments (3)

post-template.diff (488 bytes) - added by imwebgefunden 16 years ago.
Patch for wp-includes/post-template.php
post.diff (1.2 KB) - added by imwebgefunden 16 years ago.
Patch for wp-includes/post.php
6939.diff (1.6 KB) - added by wojtek.szkutnik 14 years ago.

Download all attachments as: .zip

Change History (23)

16 years ago

Patch for wp-includes/post-template.php

16 years ago

Patch for wp-includes/post.php

#1 @chodo
16 years ago

This is a very useful patch!
I think it should be included in Wordpress.
Works like a charm for me.

#2 @ryan
16 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

#3 @anonymized_154007
16 years ago

Don't know if this help, but I can confirm that this bug is still present in WordPress 2.6.

#4 @rovo89
15 years ago

  • Keywords has-patch added

I agree that this is a very useful patch and should be included in the next release. That is the one thing I have to change in the core after each update, although I use:

... WHERE (post_type = 'page' AND " . get_private_posts_cap_sql('page') . ") ...

The get_private_posts_cap_sql function does basically the same as in the patch here, but is already included in Wordpress and additionally lists the user's own private pages, even if they have no permission to read private posts.

#5 @Denis-de-Bernardy
15 years ago

  • Keywords neesd-patch close added; has-patch removed
  • Milestone changed from 2.9 to Future Release
  • Type changed from defect (bug) to enhancement

suggesting wontfix, personally. private pages don't belong in that menu. or then:

  • we should at least add an option to show them, off by default, for performance reasons
  • we may gain advantage to grab all pages, private or not, and use the walker to remove the private ones

#6 @Denis-de-Bernardy
15 years ago

  • Keywords needs-patch added; neesd-patch removed

#7 @sillybean
14 years ago

Respectfully disagreeing; private pages absolutely do belong in this menu. Where else would they go? Most sites have a single navigation menu. It makes sense to include the private pages there when needed rather than requiring a separate menu for them.

#8 @sillybean
14 years ago

  • Cc steph@… added

#9 @nacin
14 years ago

See also #8592

#10 @sirzooro
14 years ago

  • Cc sirzooro added

#11 @voyagerfan5761
14 years ago

  • Cc WordPress@… added

#12 @Denis-de-Bernardy
14 years ago

  • Keywords bug-hunt added

#13 @Denis-de-Bernardy
14 years ago

  • Keywords featured added; close bug-hunt removed

#14 @wojtek.szkutnik
14 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch gsoc needs-testing added; needs-patch wp_list_pages read_private_pages removed

#15 @sillybean
13 years ago

The patches on #8592 should resolve this problem and #4711.

#16 follow-up: @nacin
10 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #8592.

#17 in reply to: ↑ 16 @husobj
9 years ago

Replying to nacin:

Duplicate of #8592.

Is this a duplicate of that ticket or just related?

This ticket relates to wp_list_pages().
That ticket relates to wp_dropdown_pages().

Both functions use get_pages() - I guess in that respect they are duplicates, but should they be considered separately (or in tandem) as wp_dropdown_pages() is used for page->parent management in core and may have more related issues, whereas wp_list_pages() is primarily a front-end function... or am I assuming too much there?

#18 @marjanvenema
9 years ago

I don't quite understand why this ticket is closed? Has there been a regression?

I am using WordPress 4.1.1

A plugin I am using uses wp_list_pages (according to @husobj who is the author) to do its thing and when I use it, private pages don't get displayed even though I am logged in (as the admin).


#19 follow-up: @DrewAPicture
9 years ago

@husobj, @marjanvenema: The ticket was marked as a duplicate of #8592, which just means discussion should happen over on the other ticket.

To answer @husobj's question: You're basically spot on. The reason why it's a duplicate is because the change (if it happens) is going to happen in get_pages(), which both functions use.

Last edited 9 years ago by DrewAPicture (previous) (diff)

#20 in reply to: ↑ 19 @husobj
9 years ago

Replying to DrewAPicture:

To answer @husobj's question: You're basically spot on. The reason why it's a duplicate is because the change (if it happens) is going to happen in get_pages(), which both functions use.

Thanks for clarifying :)

Note: See TracTickets for help on using tickets.