strangerstudios / paid-memberships-pro

The Trusted Membership Platform That Grows with You: Restrict access to content and charge recurring subscriptions using Stripe, PayPal, and more. Fully open source. 100% GPL.
https://www.paidmembershipspro.com
Other
469 stars 359 forks source link

pmpro_member shortcode does not return fields data #1672

Open ipokkel opened 3 years ago

ipokkel commented 3 years ago

Describe the bug When using the shortcode to display user data, e.g. [pmpro_member fields="display_name"], the phrase "Array" is returned instead of the data.

To Reproduce Steps to reproduce the behavior:

  1. Go to any page and add the shortcode [pmpro_member fields="display_name"] and save
  2. As a logged in user with a valid membership level visit the test page.
  3. Array is displayed instead of the user's display name.

Expected behavior The relevant user data is expected to show.

Isolating the problem (mark completed items with an [x]):

Notes Here's the entry from debug log when calling the shortcode to display user data.

[15-Jun-2021 05:27:44 UTC] PHP Notice:  Array to string conversion in C:\Users\Admin\Local Sites\202106\app\public\wp-includes\shortcodes.php on line 343
[15-Jun-2021 05:27:44 UTC] PHP Stack trace:
[15-Jun-2021 05:27:44 UTC] PHP   1. {main}() C:\Users\Admin\Local Sites\202106\app\public\index.php:0
[15-Jun-2021 05:27:44 UTC] PHP   2. require() C:\Users\Admin\Local Sites\202106\app\public\index.php:17
[15-Jun-2021 05:27:44 UTC] PHP   3. require_once() C:\Users\Admin\Local Sites\202106\app\public\wp-blog-header.php:19
[15-Jun-2021 05:27:44 UTC] PHP   4. include() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\template-loader.php:106
[15-Jun-2021 05:27:44 UTC] PHP   5. get_template_part() C:\Users\Admin\Local Sites\202106\app\public\wp-content\themes\memberlite\page.php:20
[15-Jun-2021 05:27:44 UTC] PHP   6. locate_template() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\general-template.php:204
[15-Jun-2021 05:27:44 UTC] PHP   7. load_template() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\template.php:676
[15-Jun-2021 05:27:44 UTC] PHP   8. require() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\template.php:732
[15-Jun-2021 05:27:44 UTC] PHP   9. the_content() C:\Users\Admin\Local Sites\202106\app\public\wp-content\themes\memberlite\components\page\content-page.php:12
[15-Jun-2021 05:27:44 UTC] PHP  10. apply_filters() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\post-template.php:253
[15-Jun-2021 05:27:44 UTC] PHP  11. WP_Hook->apply_filters() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\plugin.php:212
[15-Jun-2021 05:27:44 UTC] PHP  12. do_shortcode() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\class-wp-hook.php:292
[15-Jun-2021 05:27:44 UTC] PHP  13. preg_replace_callback() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\shortcodes.php:218
[15-Jun-2021 05:27:44 UTC] PHP  14. do_shortcode_tag() C:\Users\Admin\Local Sites\202106\app\public\wp-includes\shortcodes.php:218
sc0ttkclark commented 3 years ago

The debug log doesn't mention PMPro, which I think is odd because the shortcode does not look wrong. The log itself shows the Memberlite theme in the stack but never gets to the shortcode callback itself for PMPro.

It leads to this line in WP Core causing the problem:

$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];

This would need much more debugging on the site in question to determine the real cause since we can rule out PMPro itself.

MaryOJob commented 3 weeks ago

A similar issue was encountered, the membership name and ID and or end date would only return the said data for the first level on file for the user, where they hold more than one level, this returns only the first level and the end date for that level if it exists.

Moderators Only: #601664