Skip to content

Add normalized contact data for anonymous users - #2977

Open
RabbiIslamRony wants to merge 1 commit into
developmentfrom
add/anonymous-user-contact
Open

Add normalized contact data for anonymous users#2977
RabbiIslamRony wants to merge 1 commit into
developmentfrom
add/anonymous-user-contact

Conversation

@RabbiIslamRony

@RabbiIslamRony RabbiIslamRony commented Aug 24, 2026

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

Main issue

Directorist extensions currently receive a WP_User only for registered visitors. A true guest flow has no reusable Core contract for carrying a sanitized email and display name, so extensions such as Booking can end up creating a WordPress account only to obtain contact data. That contradicts the expected guest-booking behavior and can trigger unwanted account emails.

What changed

  • Added directorist_get_user_contact() for registered and anonymous contacts.
  • Registered users resolve from WP_User or user ID.
  • Anonymous callers can supply sanitized fallback email and name values.
  • Added the directorist_user_contact filter for extension-specific adjustments.

How to test

  1. Check out this Core PR together with the companion Booking PR listed below.
  2. Run:
    wp eval '$contact = directorist_get_user_contact( 0, [ "email" => "guest@example.com", "name" => "Guest User" ] ); print_r( $contact );'
  3. Confirm the result contains id => 0, guest@example.com, and Guest User.
  4. Call the helper with a real user ID and confirm it returns that user's saved email and display name instead of the fallback.
  5. Complete the guest-booking test from the companion PR and confirm no WordPress user is created.

Dependency / companion PR

Any linked issues

CI note

The repository PHPCS workflow currently exits before scanning code because composer phpcs supplies no file/directory and phpcs.xml has no default <file> target. A targeted local PHPCS run on includes/helper-functions.php completed with zero errors.

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant