• Resolved Patrick Daly

    (@developdaly)


    I’m accessing the function add_subscription directly from within in my theme and it kept failing. I tracked it down to a typo in the function.

    Lines 611-616:

    public function add_subscription($_post_id = 0, $_email = '', $_status = 'Y'){
    		global $wpdb;
    
    		// Does the post exist?
    		$target_post = get_post($post_id);
    		if (($post_id > 0) && !is_object($target_post))

    … the last two lines should be using $_post_id instead of $post_id.

    https://www.ads-software.com/plugins/subscribe-to-comments-reloaded/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @patrick Daly I checked it out and the post id is save correcty on the database, but if you use the function outside of the plugin you may encounter this kind of behavior.

    Can you tell me how are you using it so that I can help you to solve this out or if I find how this is affecting the plugin then fix it.

    Regards !!

    Thread Starter Patrick Daly

    (@developdaly)

    The function will work in most cases because the actual insertion query a few lines later is correct, $wpdb->query($wpdb->prepare(". But the part of the function checking if the post exists doesn’t work and results in a PHP NOTICE. Most users wouldn’t see this … even with verbose error reporting turned on. I’m adding/deleting subscriptions on the front-end of my site with ajax though, and the NOTICE is returned in the response and breaks my output.

    Alright, so let me change to $_post_ID and debug the application to make sure everything works alright.

    @patrick Daly Thank you for reporting this. This has been fixed in the development trunk (see https://github.com/stcr/subscribe-to-comments-reloaded/commit/5d20eaf7ef91c83db1798bd83991770346141215 ) and this will go out with the next release.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘BUG: Undefined $post_id’ is closed to new replies.