groups_check_slug( string $slug )
Provide a unique, sanitized version of a group slug.
Description
Parameters
- $slug
-
(Required) Group slug to check.
Return
(string) $slug A unique and sanitized slug.
Source
File: bp-groups/bp-groups-functions.php
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | function groups_check_slug( $slug ) { $bp = buddypress(); // First, make the proposed slug work in a URL. $slug = sanitize_title( $slug ); if ( 'wp' == substr ( $slug , 0, 2 ) ) $slug = substr ( $slug , 2, strlen ( $slug ) - 2 ); if ( in_array( $slug , ( array ) $bp ->groups->forbidden_names ) ) $slug = $slug . '-' . rand(); if ( BP_Groups_Group::check_slug( $slug ) ) { do { $slug = $slug . '-' . rand(); } while ( BP_Groups_Group::check_slug( $slug ) ); } return $slug ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.