• I use WP-Members, Elementor and I try to put on posts grids whose content is filtered. I tried several plugins including Royal Elementor Addons but also without going through Elementor, Rays Grid, etc. When the user is logged in, the page is displayed correctly. But when the visitor is not connected (on free access pages without connection) the same error message appears repeatedly: Warning: array_merge(): Expected parameter 1 to be an array, string given in / homepages/18/d832490573/htdocs/app832594168/wp-content/plugins/wp-members/includes/class-wp-members.php on line 1279 I don’t know how to solve the problem. Can you help me ?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    The error you’ve noted would indicate that the “post__not_in” value of $query->query_vars['post__not_in'] is not an array. This is part of WP’s WP_Query class, and it shouldn’t be a string, and it should also not be not set.

    In the section of code you’ve noted, WP-Members is merging any hidden posts into the existing array of post__not_in. Because WP sets post__not_in as an empty array initially, and also requires this value to be an array, WP-Members expects it to be an array – either empty, or with values.

    But keep in mind this value can be filtered by other plugins as well, so it is possible for some other plugin to either set it as a string (not likely, but could happen) or drop it altogether (seems more likely). So it would seem the problem is something that is providing what would either be an invalid value for post__not_in or is dropping it altogether.

    That’s entirely a localized problem – either another plugin or your theme, so it’s impossible for me to tell you what exactly is causing it. However, there is one thing you could try. If the issue is that something unsets post__not_in from the $query->query_vars array, the plugin could check that and act accordingly.

    In the plugin file includes/class-wp-members.php at line 1279 (or around there, depending on the version), you should see this line:

    $post__not_in = array_merge( $query->query_vars['post__not_in'], $hidden_posts );

    Change that to the following:

    if ( ! isset( $query->query_vars['post__not_in'] ) ) {
         $post__not_in = $hidden_posts;
    }
         $post__not_in = array_merge( $query->query_vars['post__not_in'], $hidden_posts );
    }

    I ordinarily would never recommend changing a core plugin file, since that is not updatable. However, if this solves the issue, then it may be something that I consider changing in the plugin as a self-check to make sure something/someone has not altered the post__not_in value to something that breaks.

Viewing 1 replies (of 1 total)

The topic ‘class-wp-members.php array_merge(): Expected parameter 1 to be an array’ is closed to new replies.