#21142 closed enhancement (fixed)
Add a filter to domain_exists() function
Reported by: | jamescollins | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Multisite | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In Multisite, the domain_exists() function is used by WordPress to "check whether the specified blogname is already taken", however it doesn't provide any filter so that plugins can override the result.
Our Use Case:
On our multisite installs, we allow users to change their subdomain name (or domain name).
We keep a list of their previously used subdomains/domains, and if there is a HTTP request for one of their old domains, we automatically perform a 301 redirect to the new domain name.
However, we also want to make sure that other users cannot use any subdomain/domain name that has been used by another user.
Currently we have no way to override the return value of the domain_exists() function, which means we can't easily prevent other people from signing up for sites that use a domain/subdomain name
Suggestion:
Add a simple filter to the end of the domain_exists() function. See attached patch.
Attachments (2)
Change History (13)
#2
@
12 years ago
Apologies for the mess here with the sunrise attachments.
The original 21142_domain_exists.diff patch is still valid, and adding it shouldn't cause any backwards compatibility issues.
#3
@
12 years ago
- Keywords reporter-feedback added
There's a 'wpmu_validate_blog_signup' filter. Can't you use that?
#4
@
12 years ago
I think the 'wpmu_validate_blog_signup ' filter would be ok for when people create blogs via wp-signup.php, but that filter doesn't fire when a super admin creates a site via the network admin dashboard screen.
The description of the domain_exists() function is:
Check whether a blogname is already taken
Used during the new site registration process to ensure that each blogname is unique.
So I think the domain_exists() function is a much more semantically correct place to check if the specified domain name has been used.
Thanks
#5
@
12 years ago
- Keywords reporter-feedback removed
- Milestone changed from Awaiting Review to 3.5
Right, except most of the checks in wpmu_validate_blog_signup() would be useful to run even when a super-admin is creating a blog.
#7
@
12 years ago
I just checked, and wpmu_validate_blog_signup()
isn't used at all when creating a site via wp-admin/network/site-new.php
.
At present it seems that we assume that super admins know what they are doing when creating sites, which is why we perform very few checks when they create a new site.
We would need to come to a consensus as to which checks in wpmu_validate_blog_signup()
should apply when creating sites via the network admin screen. At this stage I would think most of those checks shouldn't apply when a super admin is creating a site.
Worth a discussion though.
Although that discussion is possibly separate to the simple 'domain_exists' filter in my patch.
#8
follow-up:
↓ 9
@
12 years ago
- Keywords needs-refresh commit added
Is there really no other decent filter in the stack to stop a site from being created from site-new.php? It looks like all we do is wp_die() anyway. Also, if wpmu_create_blog() fails, we still create the user. Seems like the whole set of error checking should probably improve.
I'm okay with a filter here, either way. Would be nice if it could set $result, then pass $result to the filter. Otherwise, the line gets long and it's not easy to see what kind of context is passed to the filter.
#9
in reply to:
↑ 8
@
12 years ago
- Keywords needs-refresh removed
Replying to nacin:
I'm okay with a filter here, either way. Would be nice if it could set $result, then pass $result to the filter. Otherwise, the line gets long and it's not easy to see what kind of context is passed to the filter.
21142_2.diff
implements this - thanks for the suggestion nacin!
Please ignore the sunrise.php attachment in this ticket - it was meant for #21143 instead.