Troubleshooting Common PHP Notices and Warnings in the Members Plugin
Content
If you use the 'Members – Membership & User Role Editor Plugin' and have WordPress debugging enabled, you might occasionally see PHP notices or warnings in your logs or on your screen. These messages, while often non-critical, can be annoying and clutter error logs, making it harder to spot genuine problems. This guide covers the most common ones and how to resolve them.
Common Error: 'Trying to get property of non-object' in template.php
The Error: You see a notice like PHP Notice: Trying to get property 'post_parent' of non-object in .../plugins/members/inc/template.php on line 95.
Why It Happens: This typically occurs when a theme or another plugin incorrectly triggers code that expects a valid post object (like on a 404 page, an empty archive, or during a REST API request) where no post exists. The code attempts to access a property of a post that doesn't exist.
How to Fix It:
- Update the Plugin: Ensure you are running the latest version of the Members plugin, as some related fixes have been implemented over time.
- Identify the Culprit: This notice is often a symptom of a conflict. Try temporarily switching to a default WordPress theme (like Twenty Twenty-Four) and disabling other plugins to identify which one is causing the code to run out of context.
- Adjust Debug Settings: If the notice is merely a nuisance and your site functions correctly, you can prevent it from displaying on-screen by ensuring
WP_DEBUG_DISPLAYis set tofalseandWP_DEBUG_LOGis set totruein yourwp-config.phpfile. This will log errors to a file instead.
Common Error: 'in_array() expects parameter 2 to be array'
The Error: You see a warning like Warning: in_array() expects parameter 2 to be array, bool given in .../members/members.php on line 446.
Why It Happens: This is usually caused by a bug in a specific plugin version where a function expects an array but receives a different data type, like a boolean or null value.
How to Fix It:
- Update Immediately: This specific issue was addressed in a plugin update. Updating to the latest version of the Members plugin should resolve it completely.
Common Error: Cron Event 'members_admin_notifications_update' Fails or is Delayed
The Error: Your Site Health tool shows a message that the members_admin_notifications_update event has failed or been delayed.
Why It Happens: This scheduled task checks for plugin update notifications from the Members team. The error indicates your site's WP-Cron system, which handles scheduled tasks, is not running correctly. This is especially common on sites that disable the default WP-Cron in favor of a system cron job, as the configuration might need adjustment.
How to Fix It:
- Don't Panic: This alert does not affect your site's core functionality, membership features, or user roles. It only pertains to update notifications.
- Check Your Cron System: If you use a server-level cron job, ensure it is configured properly to frequently call your site's
wp-cron.phpfile (e.g.,wget -q -O- https://yoursite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1). - Do Not Manually Delete: While you might see this event in a tool like WP Crontrol, manually deleting it is not recommended as it is likely to be recreated by the plugin and may cause further errors.
General Best Practices
- Keep Everything Updated: Always run the latest versions of WordPress, the Members plugin, and your theme. Many warnings are patched in subsequent releases.
- Manage Debugging: Use
WP_DEBUGon a development/staging site, not on a live production site. If you need to log errors on a live site, setWP_DEBUG_DISPLAYto false andWP_DEBUG_LOGto true. - Conflict Testing: Isolate issues by testing with a default theme and no other plugins active, then reactivating them one by one.
Most of these notices are minor and won't break your site. Following these steps should help you clean up your error logs and maintain a smoothly running WordPress site with the Members plugin.
Related Support Threads Support
-
PHP WARNINGhttps://wordpress.org/support/topic/php-warning-196/
-
PHP 8 Warning – inc/class-registry.phphttps://wordpress.org/support/topic/php-8-warning-inc-class-registry-php/
-
Warning in template.php filehttps://wordpress.org/support/topic/warning-in-template-php-file/
-
withState depreciatedhttps://wordpress.org/support/topic/withstate-depreciated/
-
PHP Notice Error Loghttps://wordpress.org/support/topic/php-notice-error-log/
-
Trying to get property ‘post_parent’ of non-object in template.php on line 95https://wordpress.org/support/topic/trying-to-get-property-post_parent-of-non-object-in-template-php-on-line-95/
-
PHP Notice: Trying to get property ‘post_parent’ of non-object in…https://wordpress.org/support/topic/php-notice-trying-to-get-property-post_parent-of-non-object-in/
-
PHP 8.0 Supporthttps://wordpress.org/support/topic/php-8-0-support-5/
-
PHP Notice: Trying to get property ‘name’ of non-objecthttps://wordpress.org/support/topic/php-notice-trying-to-get-property-name-of-non-object/
-
Warning appearinghttps://wordpress.org/support/topic/warning-appearing/
-
Showing Deprecation Notice and Headers Already Sent with PHP 8.2 and WP 6.2.2https://wordpress.org/support/topic/showing-deprecation-notice-and-headers-already-sent-with-php-8-2-and-wp-6-2-2/
-
Error messages when editing a posthttps://wordpress.org/support/topic/error-messages-when-editing-a-post/
-
“unrecognized upgrade type=translation” in error logs after updatehttps://wordpress.org/support/topic/unrecognized-upgrade-typetranslation-in-error-logs-after-update/
-
Warnings after update to 3.0.2https://wordpress.org/support/topic/warnings-after-update-to-3-0-2/
-
Warnings and notices with editor usershttps://wordpress.org/support/topic/warnings-and-notices-with-editor-users/
-
Notice on 404 pagehttps://wordpress.org/support/topic/notice-on-404-page/
-
cron error – members_admin_notifications_updatehttps://wordpress.org/support/topic/cron-error-members_admin_notifications_update-2/
-
Cron Event – members_admin_notifications_updatehttps://wordpress.org/support/topic/cron-event-members_admin_notifications_update/
-
Gutenberg Conflicthttps://wordpress.org/support/topic/gutenberg-conflict-2/
-
Warning: in_array() expects parameter 2 to be array, null givenhttps://wordpress.org/support/topic/warning-in_array-expects-parameter-2-to-be-array-null-given-5/
-
PHP Deprecated Warning in `members-acf-integration` Pluginhttps://wordpress.org/support/topic/php-deprecated-warning-in-members-acf-integration-plugin/
-
Dependabot Critical Security Vulns for Members 3.2.2https://wordpress.org/support/topic/dependabot-critical-security-vulns-for-members-3-2-2/
-
Site Health Issue: A scheduled event has failedhttps://wordpress.org/support/topic/site-health-issue-a-scheduled-event-has-failed/
-
Creating default object from empty value inhttps://wordpress.org/support/topic/creating-default-object-from-empty-value-in-2/
-
Notice given on Archive page when there are no postshttps://wordpress.org/support/topic/notice-given-on-archive-page-when-there-are-no-posts/
-
An alert will appear in Site Health.https://wordpress.org/support/topic/an-alert-will-appear-in-site-health/