
WordPress代码生成器如何加快开发速度
username_exists ( $username )
username_exists: 这个函数检查一个给定的用户名是否已经存在于WordPress数据库中。
确定给定的用户名是否存在。
关于这个和类似的主题功能的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。
function username_exists( $username ) { $user = get_user_by( 'login', $username ); if ( $user ) { $user_id = $user->ID; } else { $user_id = false; } /** * Filters whether the given username exists. * * @since 4.9.0 * * @param int|false $user_id The user ID associated with the username, * or false if the username does not exist. * @param string $username The username to check for existence. */ return apply_filters( 'username_exists', $user_id, $username ); }