Error with code on e-Newsletter Plugin

Get this error on the plugin. I've disabled all other plugins and checked one by one if there is a conflict and nothing changed the error. Access support granted.

  • jimmy_acton
    • Site Builder, Child of Zeus

    Notice: Trying to get property of non-object in /var/zpanel/hostdata/user27648/public_html/smallukbusinessloans_com/wp-content/plugins/e-newsletter/email-newsletter-files/builder/class.builder.php on line 21 Notice: Trying to get property of non-object in /var/zpanel/hostdata/user27648/public_html/smallukbusinessloans_com/wp-content/plugins/e-newsletter/email-newsletter-files/builder/class.builder.php on line 22

  • Rupok
    • Support Ninja

    jimmy_acton Hi jimmy_acton, hope you had a wonderful day.

    I just tried to regenerate the issue on my test site, but I could not. So this is your site specific issue and I'm not sure why this is showing there.

    Can you please try the solution I provided here? https://premium.wpmudev.org/forums/topic/functions-error-notice-trying-to-get-property-of-non-object-in-classbuilderphp-on-line-368?replies=10#post-1080775

    Please NOTE, on that thread, the error was generating on line 368, but here, the problem is on line 21 and 22. So can you open this (/var/zpanel/hostdata/user27648/public_html/smallukbusinessloans_com/wp-content/plugins/e-newsletter/email-newsletter-files/builder/class.builder.php) file and find the following lines in line 21 & 22?

    delete_transient('builder_email_id_'.$current_user->ID);
    					set_transient('builder_email_id_'.$current_user->ID, $builder_id);

    and replace these two with the following code block?

    if (is_object($current_user)) {
    					delete_transient('builder_email_id_'.$current_user->ID);
    					set_transient('builder_email_id_'.$current_user->ID, $builder_id);
    				}

    It should work. If it doesn't, please let us know. We will be glad to help further.

    Have a nice day. Cheers!
    Rupok

  • Nithin
    • Support Wizard

    Hi jimmy_acton,

    Hope you are doing good today. :slight_smile:

    Implemented and still not working?

    Are you still getting the same notices, or different one? The above solution posted by Rupok, should have removed it.

    These logs are more of a notice, and not any fatal error, and doesn't tend to break the website, or any plugin functionality. Turning the debug mode off would disable these notices, as it's not recommended to enable debug mode in live sites, unless it's meant for testing.

    If you still think you want to remove these notices, I have attached the modified file below as mentioned by Rupok, please replace the file as described above, and check whether you are still getting the same error logs, or different ones. So that we could give a closer look.

    Please let us know how that goes. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Nithin
    • Support Wizard

    Hi jimmy_acton,

    Hope you are doing good today. :slight_smile:

    I made the following changes, to the mentioned line 370, in the class.builder.php file:

    function get_builder_email_id() {
    		global $current_user, $email_newsletter;
    
    		if (is_object($current_user)) {
    			return get_transient('builder_email_id_'.$current_user->ID);
    		}
    
    		else {
    			return false;
    		}
    	}

    I have attached the file below, could you please try the following attached file, and check whether it works.

    I hope this helps. Please let us know if you still need any further assistance. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.