The members members sanitize role function.
Published Date - July 31, 2023
Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
members_sanitize_role( $role );
$role
The following example is for adding a hook callback.
if ( !function_exists( 'members_sanitize_role' ) ) {
require_once ABSPATH . PLUGINDIR . 'membersmembers/inc/functions-roles.php';
}
// The input(s).
$role = null;
// NOTICE! Understand what this does before running.
$result = members_sanitize_role( $role );
The function is defined in the following location(s).
members/inc/functions-roles.php
function members_sanitize_role( $role ) {
$_role = strtolower( $role );
$_role = preg_replace( '/[^a-z0-9_\-\s]/', '', $_role );
return apply_filters( 'members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
}