bp_members_signup_with_subdirectory_blog( array $illegal_names = array() )

Make sure the username is not the blog slug in case of root profile & subdirectory blog.


Description Description

If BP_ENABLE_ROOT_PROFILES is defined & multisite config is set to subdirectories, then there is a chance site.url/username == site.url/blogslug. If so, user’s profile is not reachable, instead the blog is displayed. This filter makes sure the signup username is not the same than the blog slug for this particular config.


Parameters Parameters

$illegal_names

(Optional) Array of illiegal names.

Default value: array()


Top ↑

Return Return

(array) $illegal_names


Top ↑

Source Source

File: bp-members/bp-members-filters.php

function bp_members_signup_with_subdirectory_blog( $illegal_names = array() ) {
	if ( ! bp_core_enable_root_profiles() ) {
		return $illegal_names;
	}

	if ( is_network_admin() && isset( $_POST['blog'] ) ) {
		$blog = $_POST['blog'];
		$domain = '';

		if ( preg_match( '|^([a-zA-Z0-9-])$|', $blog['domain'] ) ) {
			$domain = strtolower( $blog['domain'] );
		}

		if ( username_exists( $domain ) ) {
			$illegal_names[] = $domain;
		}

	} else {
		$illegal_names[] = buddypress()->signup->username;
	}

	return $illegal_names;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.