Skip to content

Guest Likes

How guest like tracking works and what gets stored in the database.

Overview

Simple Post Like supports likes from non-logged-in visitors. Guest likes are opt-in — disabled by default on fresh installs, and controlled from Settings → Simple Post Like → Allow Guest Likes.

When enabled, guests can like and unlike posts just like logged-in users. Their likes persist across page loads and browser sessions using a hashed identifier — no cookies, no accounts, no raw personal data stored.


How Guest Tracking Works

When a guest likes a post, Simple Post Like generates a SHA-256 hash from two pieces of data:

php

hash( 'sha256', $ip_address . NONCE_SALT )
  • $ip_address — the visitor’s IP address, retrieved server-side
  • NONCE_SALT — a secret string unique to your WordPress installation, defined in wp-config.php

The resulting hash is a 64-character hexadecimal string. This hash — never the raw IP — is what gets stored in the database alongside the post ID.


Why This Approach

No raw IP addresses stored. The hash is one-way — you cannot reverse it to recover the original IP. Even if your database were exposed, no personal data would be revealed.

Site-specific. The hash includes your site’s NONCE_SALT, so the same visitor produces a different hash on every WordPress site. Hashes from one site cannot be correlated with hashes from another.

No cookies required. Unlike many like plugins that set a frontend cookie to track guest likes, Simple Post Like tracks entirely server-side. This means likes persist even when a visitor clears their cookies, uses a different browser, or has cookies disabled — as long as their IP address remains the same.

No personal data stored. Because the hash is non-reversible and site-specific, it does not qualify as personal data under GDPR. No consent banner or data processing disclosure is required for this feature specifically — though you should always consult your own legal advice for your specific situation.


Database Storage

Guest likes are stored in the {prefix}_spl_likes table alongside logged-in user likes. The table schema is:

ColumnTypeDescription
idBIGINTAuto-increment primary key
post_idBIGINTThe liked post ID
user_idBIGINTWordPress user ID — 0 for guests
user_ip_hashVARCHAR(64)SHA-256 hash — empty string for logged-in users
liked_atDATETIMETimestamp of the like

For logged-in users, user_id is set and user_ip_hash is empty. For guests, user_id is 0 and user_ip_hash holds the SHA-256 hash.


Disabling Guest Likes

When Allow Guest Likes is disabled:

  • Guest visitors see the like button and the current like count
  • Clicking the button has no effect — the AJAX handler returns early
  • No guest data is written to the database
  • Existing guest likes already in the database are preserved and still counted

Only logged-in users can like posts when this setting is disabled.


Logged-in Users vs Guests

BehaviorLogged-in UserGuest
Can like postsAlwaysOnly if guest likes enabled
Tracked byWordPress user IDSHA-256 hashed IP
Persists across sessionsYesYes (same IP)
Persists across devicesYesNo
Like removed if account deletedYesNo

Next Steps

On This Page