Not logged in. · Lost password · Registration disabled
Forum: Overview Files & Mods / Datein & Mods RSS
Patch: Set Categories During Initial Subscribe
Getting the category checkboxes to show up on the subscribe form is only half the battle. Without this patch, the submitted data is simply ignored.
chrisdpratt #1
Member since Feb 2010 · 3 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Patch: Set Categories During Initial Subscribe
frontend_subscribe.php:

        // ******************************************************** //
        //                      SUBSCRIBE
        // ******************************************************** //
        if ($action == "subscribe" || $action == '') {               
            $mid = post_notification_get_mid($addr);
            if(!$mid){
                post_notification_add_email($addr); //Ab bit of an overhead, but for historical reasons.
                $mid = post_notification_get_mid($addr);
            }
           
            //Add request to send mail to queue.
            $wpdb->query("INSERT INTO $t_queue (email_id, obj_id, state, type, date)
                            VALUES($mid, 0, 0, 2, '" . post_notification_date2mysql() . "')");
           
            if(is_numeric($post_id)){
                post_notification_fe_update_subscriptions($mid, array($post_id) ,2, false);
            }
           
            /* BEGIN Patch */
            if($_POST['pn_set_post_cat']){       
                post_notification_fe_update_subscriptions($mid,$_POST['pn_post_cat'] ,0);
                $datasaved = true;
            }
            /* END Patch */

            //Output Page
            $content['header'] = $post_notification_strings['registration_successful'];
            $content = post_notification_ldfile('reg_success.tmpl');
            return $content; //here it ends - We don't want to show the selection screen.

        }
The author has attached one file to this post:
frontend_subscribe.php | Save   3.4 kBytes, downloaded 926 times
chrisdpratt #2
Member since Feb 2010 · 3 posts
Group memberships: Mitglieder
Show profile · Link to this post
Seems I missed a very important thing. The `post_notification_fe_update_subscriptions` function has a parameter, $mode, that affects how the categories are added. If $mode=1, the chosen categories replace default and already set categories. If $mode=0, the chosen categories are simply added to any default or already set categories.

If you have set default categories in the Post Notification settings, then you need to change that last parameter in the function call from 0 to 1, or it will force the default categories on the user even if they deselect them.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum