Skip to content

Membership "Access Granted" welcome email renders an empty resources list #73

Description

@bergy10

Which plugin?

Memberships (fchub-memberships)

What happened?

When the membership "Access Granted" welcome email sends (the "Welcome to {plan_name}!" email), the section that reads "…you have immediate access to the following resources:" renders an empty bullet — a list item containing an empty link — instead of listing the granted resources.

In the email the member actually receives, the resource list is literally:

<ul><li><a href="#"></a></li></ul>

So the member is told they have access "to the following resources:" and then shown nothing.

Environment: FCHub Memberships 1.3.1, alongside FluentCart 1.5.5 (the grant was triggered by a FluentCart purchase).

Steps to reproduce

  1. Create a membership plan with at least one immediate content rule (e.g. a WordPress page) and enable the "Access Granted" welcome email.
  2. Trigger a grant for a user — e.g. a FluentCart purchase whose product grants the plan, or a manual grant.
  3. Open the "Welcome to {plan_name}!" email the member receives.
  4. Under "…immediate access to the following resources:" you see an empty bullet with an empty link, never the actual resource title/URL.

Expected vs actual behaviour

Expected: each immediately-accessible resource should appear as a titled link (resource title → permalink).

Actual: every resource renders as <li><a href="#"></a></li> (empty title, # URL).

Likely root cause (from the source): GrantNotificationService::sendGranted() passes the plan's raw rule rows straight through as the resources array:

'resources' => array_values($immediateResources),

where $immediateResources is the plan's rule rows filtered by drip_type === 'immediate'. But AccessGrantedEmail::buildSmartCodes() expects each resource to be a ['title' => ..., 'url' => ...] pair:

$title = esc_html($resource['title'] ?? '');
$url   = esc_url($resource['url'] ?? '#');

The rule rows only contain provider / resource_type / resource_id — no title or url — so every entry resolves to an empty title and a # URL.

Suggested fix: map each rule to {title, url} before passing it to the email — resolve resource_id → post title + permalink for wordpress_core page/post resources, and skip or label non-content triggers such as fluent_cart/product. Alternatively, have AccessGrantedEmail do that resolution itself. It may also help to omit the "following resources:" heading when the resolved list is empty.

WordPress version

7.0.2

PHP version

8.5.8

FluentCart version

1.5.5

Plugin version

1.3.1

Screenshots or logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions