Support » Plugin: WP-Members Membership Plugin » 2 PHP notices keep reappearing in debug.log

  • Using the following header widget area HTML widget (Genesis child team):

    [wpmem_logged_out] <span class="icon icon-user">Log in
    [wpmem_form login]
    [/wpmem_logged_out]
    [wpmem_logged_in] [wpmem_field user_login] | 
    [wpmem_logout]<span class="icon icon-user"></span>Log out[/wpmem_logout]
    [/wpmem_logged_in]

    And the following PHP notices in the /wp-content/debug.log never stop:

    [28-Jan-2019 06:29:50 UTC] PHP Notice:  Undefined offset: 0 in .../wp-content/plugins/wp-members/inc/class-wp-members-forms.php on line 637
    [28-Jan-2019 06:39:02 UTC] PHP Notice:  Trying to get property of non-object in .../wp-content/plugins/wp-members/inc/class-wp-members-forms.php on line 634

    WordPress 5.03
    Genesis 2.7.3
    WP-Members 3.2.5.1
    But the issue has been present also on older versions of WP (from abt 4.9.x), Genesis (from abt 2.5) and WP-Members (3.1.x), just did not bother to report as hoped it will go away with next update.

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

    (@cbutlerjr)

    What is causing the notice is where this shortcode is being used, WP’s $post object is not set. The reason for the problem is where you are using the shortcode. When you’re using it in the header, it is quite likely that The Loop is not run there and so there is no $post object at that point.

    This occurs in the login form builder function. The login form generated by the shortcode is intended use is the main content area, and the function is used in quite a few different instances. In those use cases, get_the_ID() would function just fine. But if used outside The Loop, it will return false (0) since $post is not set, so you get the undefined offset notice. The other notice is that the $post object is used to check the post content, and the $post object is not set.

    So that’s the reason the notice is occurring for you. It would never show up in testing since the shortcode isn’t on the test site in the same way you have implemented it, so simply not reporting it I would have never been aware. Since people use the plugin in all kinds of different ways, it would be impossible for me to test for every possibility, even though I try to account for as many as I can.

    That being said, I want the plugin to be as flexible as possible, so it’s definitely something that I can review for some alternative to be used to get the same result needed (getting the ID of the current page). So I’ve noted it for review and hopefully we can come up with a decent alternative that still fulfills the necessary requirements in this section of the form.

    Thanks for prompt response!
    Is there a smarter way to have compact login form in the header?

    I have first tried to achieve needed results using a WP-Members sidebar widget (some 1.5 yrs ago) but then it did not have the same filtering possibilities and I switched to using the the form instead.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.