Errors in Events+ Admin add-ons and public event pages

I can't grant you access to the staging server for technical reasons, but I'm seeing the following errors (screenshots attached):

1. In Admin tool on Settings page, Notice: Undefined index: access_token in /home/deserth1/public_html/wp-content/plugins/events-and-bookings/lib/class_wd_wpmu_oauth.php on line 497

2. On Event page: Notice: Trying to get property of non-object in /home/deserth1/public_html/wp-content/plugins/events-and-bookings/lib/plugins/eab-events-membership2-integration.php on line 286

Strict Standards: Non-static method Eab_Template::get_root_url() should not be called statically in /home/deserth1/public_html/wp-content/plugins/events-and-bookings/lib/class_eab_template.php on line 349

  • Vaughan

    Hi JessycaFrederick

    Hope you're well?

    These are all notices and do not prevent the plugin working, the strict standards notices are due to your PHP version, but should still work ok.

    It's not recommended to have notices output to screen though.

    You can hide the notices by adding the following to your wp-config.php

    Set WP_DEBUG to false.

    Then add the following lines below it in wp-config.php so it looks like below:

    define('WP_DEBUG', false);
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );

    Now whenever you need to debug, set WP_DEBUG to true.

    Instead of notices & errors now being displayed on the site for everyone to see, it will instead write them to a file called debug.log in your /wp-content folder.

    But you can fix the Strict standards notices by doing the following:

    Open up & edit /wp-content/plugins/events-and-bookings/events-and-bookings.php

    Find the following on line 482

    $type = reset( explode( '_', current_filter() ) );

    Replace with:

    $current_filter = explode('_', current_filter());
    		$type = reset($current_filter);

    I haven't tested, but hopefully that should fix that notice.

    For the other Strict notice:

    Open up & edit /wp-content/plugins/events-and-bookings/lib/class_eab_template.php

    Find the following on line 415:

    public function get_root_url () {

    Replace with:

    public static function get_root_url () {

    But the debug lines I gave earlier, should remove the errors from the page.

    I have reported these to the developer, hopefully we can get these fixed up quickly.

    Thanks.

  • JessycaFrederick

    Ah, okay. Thanks for the super quick and thorough reply.

    I have the debugging set to output because I'm doing all kinds of custom development right now and need to know when I'm making mistakes

    Your fixes took care of some of the problems but this one persisted:

    On Event page: Notice: Trying to get property of non-object in /home/deserth1/public_html/wp-content/plugins/events-and-bookings/lib/plugins/eab-events-membership2-integration.php on line 286

    I'm not sure why the membership object isn't being created. Is this because I'm an Admin?

    The relevant code snippet is:

    public function will_show_pay_note( $show_pay_note, $event_id ) {
    		$data = $this->get_infos( $event_id );
    		$user = $this->api->get_current_member();
    
    		foreach ( $data as $membership_id => $membership ) {
    			if ( $user->has_membership( $membership_id ) ) {
    				// The member has subscribed to this membership.
    
    				if ( $membership->has_price && 0 == $membership->price ) {
    					// The membership has a custom price and custom price is 0.
    					return false;
    				}
    			}
    		}
    
    		return $show_pay_note;
    	}
  • Vaughan

    Hi,

    I can't be sure, but yes, you might be correct in it being that you're an admin so it can't determine your membership_id.

    You can try the following:

    find the following line 279

    $data = $this->get_infos( $event_id );

    Add the following right before this line:

    if(current_user_can('manage_options')) return false;

    so it looks like:

    public function will_show_pay_note( $show_pay_note, $event_id ) {
            if(current_user_can('manage_options')) return false;
    		$data = $this->get_infos( $event_id );
    		$user = $this->api->get_current_member();

    Hopefully that should fix that notice. But I haven't tested.

    Hope this helps