2 Comments
  1. I tried to edit my comment but something happened with the formatting!
    Here is the original comment:

    I don’t know of any plugin that does it but there probably is. Otherwise it’s quite an easy implementation if you know a bit of php.

    Decide the username structure. I think Reddit usernames consist of a random adjective and a random noun followed by a random number. For example, “Curious_Camel_4392”.

    Create your wordlist (Adjective and Nouns) Like this:

    $adjectives = array(“Ancient”, “Curious”, “Mysterious”, “Silent”, “Reckless”);
    $nouns = array(“Camel”, “Mountain”, “River”, “Tree”, “Cloud”);

    Using the word list you made create a function that randomizes your words and adds a few numbers to it. Like this:

    function generate_random_username($length = 4) {
    $adjectives = array(“Ancient”, “Curious”, “Mysterious”, “Silent”, “Reckless”);
    $nouns = array(“Camel”, “Mountain”, “River”, “Tree”, “Cloud”);
    $numbers = substr(str_shuffle(“0123456789”), 0, $length);

    return $adjectives[array_rand($adjectives)] . “_” . $nouns[array_rand($nouns)] . “_” . $numbers;
    }

    Create another function that hooks in to the WordPress user registration process and adds a random username according to the previous function. Like this:

    function cocio_random_username($username, $raw_username, $strict) {
    $random_username = generate_random_username(); // Call the function
    while (username_exists($random_username)) {
    $random_username = generate_random_username(); // Regenerate if exists
    }
    return $random_username;
    }
    add_filter(‘pre_user_login’, ‘cocio_random_username’, 10, 3);

    This is just a simple example and not tested. For example the hook pre_user_login runs before a user is created but also when a user is updated. Which would mean that the username will randomize everytime someone updates a user account.

  2. /**

    * Generate a random username for new user registration.

    *

    * @param string $username The username provided by the user.

    * @return string The generated random username.

    */

    function generate_random_username($username) {

    // Generate a random username using current timestamp and random number.

    $random_username = ‘user_’ . time() . ‘_’ . rand(1000, 9999);

    return $random_username;

    }

    add_filter(‘pre_user_login’, ‘generate_random_username’);

    Put this in function.php and after user creates an account a random username will be applied to it.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer