Skip to content

Add normalized contact data for anonymous users - #2976

Closed
RabbiIslamRony wants to merge 1 commit into
sovware:developmentfrom
RabbiIslamRony:investigate-client-issue-3257
Closed

Add normalized contact data for anonymous users#2976
RabbiIslamRony wants to merge 1 commit into
sovware:developmentfrom
RabbiIslamRony:investigate-client-issue-3257

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

Checklist

@RabbiIslamRony

Copy link
Copy Markdown
Member Author

Replaced by #2977 from a same-repository branch so the pull_request_target PHPCS workflow can safely check out and test the code. The implementation is unchanged.

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