Debug Mode Instructions

Version: 1.2.1 Last Updated: December 2025 Difficulty: Intermediate Time Required: 10 minutes

Overview

Debug mode reveals detailed error messages and logs that help diagnose issues. This guide shows how to enable WordPress debug mode and interpret error messages.

Enabling WordPress Debug Mode

Step 1: Edit wp-config.php

Access wp-config.php via:
  • FTP (FileZilla, WinSCP)
  • cPanel File Manager
  • SSH/command line
Find this line:

define('WP_DEBUG', false);
Replace with:

// Enable debug mode
define('WP_DEBUG', true);

// Log errors to file
define('WP_DEBUG_LOG', true);

// Don't display errors on frontend (security)
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

// Log database queries (optional, for performance issues)
define('SAVEQUERIES', true);
Save file and upload back to server.

Step 2: Check Debug Log

Log location:

/wp-content/debug.log

Access via:
  • FTP/download file
  • cPanel File Manager
  • View in text editor
Log grows large over time. Check regularly and delete when not debugging.

Understanding Error Messages

PHP Fatal Errors

Example:

PHP Fatal error: Uncaught Error: Call to undefined function attrua_get_option()

in /wp-content/plugins/attributes-user-access-pro/includes/functions.php:45

What it means:

Function doesn’t exist

Likely causes:

  • Plugin file missing/corrupt
  • Plugin not fully activated
  • PHP version incompatibility
Solution:
  • Deactivate and reactivate plugin
  • Reinstall plugin from fresh download
  • Check PHP version meets requirements

Database Errors

Example:

WordPress database error Table ‘wp_attrua_audit_log’ doesn’t exist

for query SELECT * FROM wp_attrua_audit_log

What it means:

Database table missing

Solution:
  • Deactivate plugin
  • Reactivate (triggers table creation)
  • Or run table creation SQL manually

JavaScript Errors

Check browser console:

Chrome/Edge: F12 → Console tab

Firefox: F12 → Console tab

Common errors:

“$ is not defined” → jQuery not loaded

“Uncaught TypeError” → Function doesn’t exist

“Script error” → Cross-origin issue

Plugin-Specific Debug

Attributes Debug Mode

Enable additional plugin logging:

// Add to wp-config.php
define('ATTRUA_DEBUG', true);

// This logs:

<ul>
<li>Login attempts</li></ul>

<ul>
<li>2FA verification</li></ul>

<ul>
<li>IP blocking checks</li></ul>

<ul>
<li>Redirect decisions</li></ul>

<ul>
<li>Database queries</li></ul>
View extended logs:

Users → Settings → Debug

Recent Activity:

[2025-12-19 14:30:15] Login attempt: username=john

[2025-12-19 14:30:15] IP check: 203.0.113.50 – ALLOWED

[2025-12-19 14:30:16] 2FA required: YES

[2025-12-19 14:30:16] 2FA code sent to: john@example.com

[2025-12-19 14:30:45] 2FA verified: SUCCESS

[2025-12-19 14:30:45] Redirect to: /dashboard/

Using Query Monitor Plugin

Installation

Install Query Monitor:
  • Go to Plugins → Add New
  • Search “Query Monitor”
  • Install and activate
Benefits:

✓ See all database queries

✓ See slow queries

✓ See duplicate queries

✓ See PHP errors

✓ See hook usage

✓ See HTTP API calls

✓ See template hierarchy

Reading Query Monitor

Admin toolbar shows:

⚠ 45 queries in 0.85s

⚠ 2 errors

Click to see details:

Queries by Component:

  • Attributes User Access: 12 queries (0.15s)
  • WordPress Core: 25 queries (0.50s)
  • Theme: 8 queries (0.20s)

Slow Queries (>0.05s):

SELECT * FROM wp_usermeta WHERE meta_key LIKE ‘attrua_%’ (0.12s)

Common Debug Scenarios

Scenario 1: Login Not Working

Debug steps:
  • Enable WP_DEBUG
  • Attempt login
  • Check debug.log
  • Look for:

– PHP errors

– Database errors

– Authentication failures

  • Enable ATTRUA_DEBUG for details
Typical log entries:

[19-Dec-2025 14:30:15] Attempting login for: john

[19-Dec-2025 14:30:15] wp_authenticate_user: Invalid username

→ Username doesn’t exist

OR:

[19-Dec-2025 14:30:15] Attempting login for: john

[19-Dec-2025 14:30:15] wp_check_password: FAILED

→ Wrong password

Scenario 2: Redirects Not Working

Enable redirect debugging:

// wp-config.php
define('ATTRUA_DEBUG', true);
define('ATTRUA_DEBUG_REDIRECTS', true);
Check log:

[19-Dec-2025 14:30:45] Redirect check for user ID: 5

[19-Dec-2025 14:30:45] User role: subscriber

[19-Dec-2025 14:30:45] Redirect rule match: /member-area/

[19-Dec-2025 14:30:45] Final redirect URL: https://example.com/member-area/

[19-Dec-2025 14:30:45] Redirect executed: wp_redirect()

Scenario 3: Performance Issues

Enable query logging:

// wp-config.php
define('SAVEQUERIES', true);
Check query count:

// Add to footer.php temporarily
global $wpdb;
echo "<!-- " . count($wpdb->queries) . " queries -->";
foreach ($wpdb->queries as $q) {
    if ($q[1] > 0.05) { // Queries slower than 50ms
        echo "<!-- SLOW: " . $q[0] . " (" . $q[1] . "s) -->";
    }
}

Browser DevTools

Network Tab

Monitor AJAX requests:
  • Open DevTools (F12)
  • Go to Network tab
  • Filter: XHR
  • Attempt action (login, register)
  • Check AJAX request status:

– 200: Success

– 400: Bad request

– 403: Forbidden

– 500: Server error

Console Tab

Check for JavaScript errors:
  • Open Console tab
  • Attempt action
  • Look for red error messages
  • Note file and line number

Sharing Debug Information

When Contacting Support

Provide this information:
    • WordPress version
    • PHP version
    • Plugin version
    • Active plugins list
    • Active theme
    • Relevant debug.log entries
    • Browser console errors (if applicable)
    • Steps to reproduce issue
    • Screenshots of error messages

Sanitizing Sensitive Data

Before sharing logs:

Remove:

  • Passwords (should never be in logs anyway)
  • Email addresses (replace with user@example.com)
  • IP addresses (replace with 203.0.113.1)
  • API keys / license keys
  • Database credentials

Keep:

  • Error messages
  • Stack traces
  • Query structures (without actual data)
  • Timestamps

Disabling Debug Mode

When Finished Debugging

IMPORTANT: Disable debug on production sites Edit wp-config.php:

// Change back to:
define('WP_DEBUG', false);

// Remove these:
// define('WP_DEBUG_LOG', true);
// define('WP_DEBUG_DISPLAY', false);
// define('SAVEQUERIES', true);
// define('ATTRUA_DEBUG', true);
Delete debug.log:

Delete /wp-content/debug.log

(May contain sensitive information)

Best Practices

Never Enable on Production Without Hiding Errors

Always use WP_DEBUG_DISPLAY = false on live sites. Only log to file.

Monitor Log File Size

debug.log can grow to hundreds of MB. Delete regularly.

Use Staging for Intensive Debugging

Clone production to staging. Debug there first.

Document Findings

Keep notes on errors found and solutions applied.