Make WordPress Core

Opened 7 years ago

Closed 4 years ago

#42138 closed enhancement (duplicate)

Pass post ID into assign_terms checks

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

When checking if a user can assign_terms it would be helpful to know which post ID it is that terms are potentially being assigned to.

This would allow plugins to conditionally prevent the assignment of terms to specific posts.

A few more thoughts about this idea:

  • The singular form (assign_term) already exists, and accepts a term ID, to check if a specific term ID is assignable
  • assign_terms may not always be used in the context of a single post ID
  • current_user_can() supports multiple $args, so an assign_term_to_post could, in theory, accept both the post ID and term ID at the same time, though nothing in core takes advantage of this yet. We should probably stick to independently checking each object, but I wanted to mention the idea to be thorough.

I'll post a first-pass patch at including the post ID imminently.

Attachments (1)

42138.diff (4.2 KB) - added by johnjamesjacoby 7 years ago.

Download all attachments as: .zip

Change History (5)

#1 in reply to: ↑ description ; follow-up: @johnbillion
7 years ago

  • Keywords has-patch added

Replying to johnjamesjacoby:

  • current_user_can() supports multiple $args, so an assign_term_to_post could, in theory, accept both the post ID and term ID at the same time, though nothing in core takes advantage of this yet.

Post meta checks make use of this. AFAIK it's the only place in core that does. https://core.trac.wordpress.org/browser/trunk/src/wp-includes/capabilities.php?rev=41322&marks=307#L304

#2 in reply to: ↑ 1 @johnjamesjacoby
7 years ago

Replying to johnbillion:

Post meta checks make use of this. AFAIK it's the only place in core that does. https://core.trac.wordpress.org/browser/trunk/src/wp-includes/capabilities.php?rev=41322&marks=307#L304

Oh yeah! Yay prior art!

#3 follow-up: @jeremyfelt
4 years ago

Related (duplicate?): #40950

#4 in reply to: ↑ 3 @johnjamesjacoby
4 years ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Replying to jeremyfelt:

Related (duplicate?): #40950

Definitely!

Note: See TracTickets for help on using tickets.