Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#30470 closed enhancement (fixed)

Introduce "delete_blog" capability

Reported by: thomaswm's profile thomaswm Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch needs-testing
Focuses: multisite Cc:

Description

Currently, any user with administrator privileges for one blog within a multisite network can delete this specific blog. While the creation of new blogs can be restricted to network admins in the network options, there is no such option for the deletion of blogs.

When I dug into the code of wp-admin/ms-delete-site.php, I stumbled upon the following comment in line 15:

// @todo Create a delete blog cap.
if ( ! current_user_can( 'manage_options' ) )
wp_die(__( 'You do not have sufficient permissions to delete this site.'));

I'd suggest to introduce such a capability. Then it would be possible to control who is able to delete a blog within the multisite network.

Attachments (2)

30470.diff (1.1 KB) - added by thomaswm 9 years ago.
Introduces delete_site capability and maps it to manage_options
30470.2.diff (1.8 KB) - added by thomaswm 9 years ago.
Also changes occurrence of capability in wp-admin/menu.php

Download all attachments as: .zip

Change History (8)

#1 follow-up: @jeremyfelt
10 years ago

Thanks for the ticket, @thomaswm!

This is a tough one. I completely agree that a delete_blog (or really delete_site) capability should be available. However, since manage_options has been used for years, we can't necessarily swap the two out. I'm not sure how likely it is that custom requirements would remove manage_options from the administrator role, but it's possible. It's probably more likely that manage_options has been added to a custom set of users in some cases.

We could map delete_site to manage_options in map_meta_cap()... possibly the safest bet as this would default to everyone with manage_options capabilities.

Ideas welcome. :)

#2 in reply to: ↑ 1 @johnbillion
9 years ago

Replying to jeremyfelt:

We could map delete_site to manage_options in map_meta_cap()

This is what we usually do whenever more granular capabilities are introduced.

@thomaswm
9 years ago

Introduces delete_site capability and maps it to manage_options

@thomaswm
9 years ago

Also changes occurrence of capability in wp-admin/menu.php

#3 @thomaswm
9 years ago

  • Keywords has-patch needs-testing added

#4 @jeremyfelt
9 years ago

  • Milestone changed from Awaiting Review to 4.2

#5 @jeremyfelt
9 years ago

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

In 31673:

Introduce delete_site meta capability.

Map delete_site as a meta capability to manage_options so that the ability to delete sites can be more granularly managed for individual site administrators on a multisite network.

Props thomaswm.

Fixes #30470.

#6 @nacin
9 years ago

+1 :-)

Note: See TracTickets for help on using tickets.