Back to Community

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:

  1. Update the Plugin: Ensure you are running the latest version of the Members plugin, as some related fixes have been implemented over time.
  2. 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.
  3. 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_DISPLAY is set to false and WP_DEBUG_LOG is set to true in your wp-config.php file. 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:

  1. 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:

  1. Don't Panic: This alert does not affect your site's core functionality, membership features, or user roles. It only pertains to update notifications.
  2. 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.php file (e.g., wget -q -O- https://yoursite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1).
  3. 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_DEBUG on a development/staging site, not on a live production site. If you need to log errors on a live site, set WP_DEBUG_DISPLAY to false and WP_DEBUG_LOG to 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