Skip to content

Fix: Display Taxonomy Field data in user profiles#392

Open
reygcalantaol wants to merge 4 commits intodevelopfrom
Taxonomy-Field's-data-not-displaying-in-the-user's-profile-#85
Open

Fix: Display Taxonomy Field data in user profiles#392
reygcalantaol wants to merge 4 commits intodevelopfrom
Taxonomy-Field's-data-not-displaying-in-the-user's-profile-#85

Conversation

@reygcalantaol
Copy link
Copy Markdown
Collaborator

@reygcalantaol reygcalantaol commented Nov 25, 2023

Resolves #396

Summary

Fixes taxonomy field data not displaying on user profiles. carbon_get_user_meta() returns empty for taxonomy-type fields because Carbon Fields stores taxonomy data differently. The fix bypasses Carbon Fields for taxonomy fields, using get_user_meta() instead.

Fix: Add && $this->get_type() !== 'taxonomy' to the set_user_meta() condition so taxonomy fields fall through to the standard get_user_meta() path.


Manual Test Plan

Prerequisites

  • WP User Manager + WPUM Custom Fields addon active
  • A custom taxonomy registered for users (or use the addon's taxonomy field type)

1. Create a taxonomy field

  • Go to Users > Custom Fields
  • Create a new field group (or use an existing one)
  • Add a new field with type Taxonomy
  • Select a taxonomy (e.g. a custom "Skills" taxonomy, or "Category")
  • Set visibility to Public and editing to Public
  • Save the field group

2. Add terms to the taxonomy

  • If using a custom taxonomy, add some terms (e.g. "PHP", "JavaScript", "Design")
  • Or use existing terms from the selected taxonomy

3. Set taxonomy data on a user via registration

  • Visit the Registration page
  • Expected: The taxonomy field appears on the form (as checkboxes or dropdown)
  • Register a new user and select one or more terms
  • Expected: Registration succeeds

4. Verify taxonomy data displays on profile

  • Visit the new user's frontend profile page (/profile/{username}/)
  • Expected: The selected taxonomy terms are displayed on the profile (not blank)
  • This is the core bug — before this fix, the profile showed nothing

5. Edit taxonomy data via account page

  • Log in as the user and go to the Account page
  • Change the taxonomy selection
  • Save
  • Visit the profile page again
  • Expected: The updated terms are displayed

6. Verify non-taxonomy fields still work

  • Check that other custom fields (text, dropdown, etc.) still display correctly on profiles
  • Expected: No regression — other field types are unaffected

WPUnit Test Coverage

10 tests in tests/wpunit/Fields/TaxonomyFieldDisplayTest.php:

  • Carbon branch condition is FALSE for taxonomy fields (the core fix)
  • Carbon branch condition is TRUE for text fields (no regression)
  • Value retrieval from get_user_meta() for taxonomy fields
  • Array and scalar value retrieval
  • Edge cases: invalid user ID, empty meta, non-wpum prefix

🤖 Generated with Claude Code

@wp-user-manager
Copy link
Copy Markdown
Collaborator

@reygcalantaol I couldn't recreate this issue - is it not appearing in the wp-admin user profile?

@reygcalantaol
Copy link
Copy Markdown
Collaborator Author

@polevaultweb @wp-user-manager
The issue is that the taxonomy terms selected during registration does not display in the user's profile page.

To reproduce:

@wp-user-manager
Copy link
Copy Markdown
Collaborator

@reygcalantaol very strange, still can't recreate -

Settings

image

After Registration - Profile
image

After Registration - Account edit
image

After Registration - WP Admin profile
image

@reygcalantaol
Copy link
Copy Markdown
Collaborator Author

reygcalantaol commented Mar 31, 2024

@polevaultweb
The issue is to add the user taxonomy values in the primary fields section:
image

polevaultweb added a commit that referenced this pull request Feb 23, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@polevaultweb polevaultweb force-pushed the Taxonomy-Field's-data-not-displaying-in-the-user's-profile-#85 branch from f46e92d to ed6f669 Compare February 23, 2026 18:06
@polevaultweb polevaultweb requested a review from Copilot February 26, 2026 20:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where taxonomy field data was not displaying on user profiles. The issue occurred because carbon_get_user_meta() returns empty for taxonomy-type fields, which store their data differently than standard Carbon Fields. The fix adds a type check to bypass Carbon Fields for taxonomy fields, allowing them to use the standard get_user_meta() retrieval path.

Changes:

  • Modified set_user_meta() condition in WPUM_Field class to exclude taxonomy fields from Carbon Fields retrieval path
  • Added comprehensive test suite with 10 unit tests covering branching logic, value retrieval, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
includes/fields/class-wpum-field.php Added && $this->get_type() !== 'taxonomy' condition to line 634 to exclude taxonomy fields from Carbon Fields retrieval
tests/wpunit/Fields/TaxonomyFieldDisplayTest.php New comprehensive test suite with 10 tests validating the fix and ensuring no regression for other field types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +258 to +263
if ( ! function_exists( 'wpum_passthrough_formatter' ) ) {
function wpum_passthrough_formatter( $field, $value ) {
return $value;
}
}

Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function wpum_passthrough_formatter is defined identically in two test methods (lines 221-225 and 258-262). While the function_exists() check prevents a fatal error, this is code duplication. Consider either: 1) Defining the function once in the test class setup method, 2) Using a shared helper method, or 3) Ensuring only one function definition exists and removing the duplicate from lines 258-262.

Suggested change
if ( ! function_exists( 'wpum_passthrough_formatter' ) ) {
function wpum_passthrough_formatter( $field, $value ) {
return $value;
}
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - removed the duplicate wpum_passthrough_formatter definition from the second test method. The function_exists() guard was masking the duplication.

@@ -0,0 +1,300 @@
<?php
/**
* Tests for the taxonomy field display fix (PR #392).
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header comment references "PR #392" but this appears to be a different PR. The comment should reference the correct PR number or be updated to avoid confusion.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct — the file documents tests for PR #392 (the taxonomy field display fix). The header comment accurately identifies which PR these tests belong to.

Comment on lines +17 to +18
*
* @see https://github.com/WPUserManager/wp-user-manager/pull/392
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same URL reference at line 3 is repeated here. It should reference the correct PR number to match this pull request.

Suggested change
*
* @see https://github.com/WPUserManager/wp-user-manager/pull/392

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct as written — the @see tag links to PR #392, which is the PR this test file was created for. No change needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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.

Taxonomy Field's data not displaying in the user's profileBroken functionality should (not)...

4 participants