Creating Temporary WordPress Access: Quick Guide

Need to grant temporary WordPress access without compromising security? Here’s how to do it quickly and effectively.

Using Built-in WordPress Features

The quickest method using only WordPress’s built-in functionality:

  1. Go to Users → Add New in your dashboard
  2. Create a new user with an appropriate role (avoid Administrator if possible)
  3. Generate a strong password
  4. Share credentials securely with your collaborator
  5. Important: Add a calendar reminder to delete this user when access should end
  6. When that date arrives, go to Users, select the temporary user, and delete them

Pro tip: Use the Editor role instead of Administrator whenever possible for better security.

Using Specialized Plugins

For automatic expiration, use one of these plugins:

Temporary Login Without Password

  1. Install and activate the plugin
  2. Go to Users → Temporary Logins
  3. Click “Create New”
  4. Enter email address and select role
  5. Set an expiration date
  6. Send the generated link to your collaborator

The access will automatically expire on your chosen date without any action needed from you.

User Role Editor

  1. Install and activate “User Role Editor”
  2. Create a custom role with only necessary permissions
  3. Assign this role to your temporary user
  4. Delete the user when access is no longer needed

Password Protected Access

For sharing content without dashboard access:

  1. Edit the page you want to share
  2. In the Document settings panel, find “Visibility”
  3. Select “Password protected” and set a password
  4. Update the page
  5. Share the URL and password with your collaborator

Custom Code Solution

Add this snippet to your theme’s functions.php file or in a custom plugin:

// Add this to functions.php or a custom plugin
add_action('wp_login', 'track_temp_user_login', 10, 2);
add_action('wp_loaded', 'check_temp_user_expiration');

// Track when temporary users log in
function track_temp_user_login($user_login, $user) {
    if (get_user_meta($user->ID, 'temp_access', true) === 'yes') {
        update_user_meta($user->ID, 'last_login', current_time('timestamp'));
    }
}

// Check and expire temporary users
function check_temp_user_expiration() {
    if (!is_admin()) return;
    
    $temp_users = get_users(array(
        'meta_key' => 'temp_access',
        'meta_value' => 'yes'
    ));
    
    foreach ($temp_users as $user) {
        $expiry_days = get_user_meta($user->ID, 'expiry_days', true);
        $last_login = get_user_meta($user->ID, 'last_login', true);
        
        if ($last_login && $expiry_days) {
            $expiry_time = $last_login + (intval($expiry_days) * DAY_IN_SECONDS);
            if (current_time('timestamp') > $expiry_time) {
                // Either delete the user or change role to subscriber
                $user->set_role('subscriber');
                // Optional: delete_user($user->ID);
            }
        }
    }
}

// Function to create a temporary user
function create_temp_user($username, $email, $role, $expiry_days) {
    $password = wp_generate_password(12, true, true);
    $user_id = wp_create_user($username, $password, $email);
    
    if (!is_wp_error($user_id)) {
        $user = new WP_User($user_id);
        $user->set_role($role);
        
        update_user_meta($user_id, 'temp_access', 'yes');
        update_user_meta($user_id, 'expiry_days', $expiry_days);
        
        return array(
            'user_id' => $user_id,
            'password' => $password
        );
    }
    
    return false;
}

To create a temporary user with this code, use:

$temp_user = create_temp_user('tempuser', 'temp@example.com', 'editor', 7);
echo "Username: tempuser, Password: " . $temp_user['password'];

Frequently Asked Questions

Q: What’s the fastest way to create temporary access? A: For one-time quick access, use the “Temporary Login Without Password” plugin. It takes less than 2 minutes to set up.

Q: How can I track what changes temporary users make? A: Install an activity log plugin like “WP Activity Log” alongside your temporary access solution.

Q: What’s the safest way to share WordPress credentials? A: Use encrypted messaging apps or password managers with sharing features. Never send login details via regular email.

Q: Can I limit access to specific parts of WordPress? A: Yes, using role editor plugins or membership plugins that allow granular permission controls.