Not logged in. · Lost password · Registration disabled
Forum: Overview Files & Mods / Datein & Mods RSS
Auto Subscribe when new user registing
syfr12 #1
Member since Jan 2009 · 4 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Auto Subscribe when new user registing
give admin an option "Auto Subscribe When New User Registing" ,Choice "yes" ,the new user will auto subscribe


change :

1 in install.php add
add_option('post_notification_auto_subscribe', 'yes','Auto Subscribe when regist new user', 'no'); 
2 in admin_settings.php
  2.1 under line  <h4> <?php  _e('Technical', 'post_notification');  ?></h4>
      add:
    <tr class="alternate">
        <th style="text-align:right;padding-right:10px;"><?php _e('Auto Subscribe When New User Registing:', 'post_notification'); ?></th>
        <td>
            <select name="auto_subscribe" >
              <option value="no"  <?php  echo $auto_subscribeN; ?> > <?php  _e('No', 'post_notification'); ?></option>
              <option value="yes" <?php  echo $auto_subscribeY; ?> > <?php  _e('Yes', 'post_notification'); ?></option>
            </select>   
        </td>
    </tr> 

   2.2 in function post_notification_admin_sub()
      add:


    update_option('post_notification_auto_subscribe', $_POST['auto_subscribe']);

    if(get_option('post_notification_auto_subscribe') == 'yes') //rather have No
        $auto_subscribeY = $selected;
    else
        $auto_subscribeN = $selected;

3 in post_notification.php
  3.1 in  function post_notification_gui_init() add:
      add_action('user_register', 'post_notification_register'); 
  3.2 add function  post_notification_register
///  Auto Subscribe for new wordpress user registion
function post_notification_register($user_id) {
    global $wpdb;     
   
    if ($user_id == 0 ) { $user_id = get_userdatabylogin($_POST['user_login']); }
  
    $auto_subscribe =  get_option('post_notification_auto_subscribe') ;
    if ($auto_subscribe == "no") { return; }
   
    if (0 == $user_id) { $user_id = (int) func_get_arg( 0 ); }
    if (0 == $user_id) { return; }      
      
        $t_emails = $wpdb->prefix . 'post_notification_emails';
        $t_cats = $wpdb->prefix . 'post_notification_cats';
       
          
        $user = get_userdata($user_id);
        $addr = $user->user_email ;
        $gets_mail = 1;
        $now = post_notification_date2mysql();
       
        $mid = $wpdb->get_var("SELECT id FROM $t_emails WHERE email_addr = '$addr'");
        if (!$mid) {
            $wpdb->query(
                    "INSERT " . $t_emails .
                    " (email_addr, gets_mail, last_modified, date_subscribed) " .
                    " VALUES ('$addr', '$gets_mail', '$now', '$now')");       
            $mid = $wpdb->get_var("SELECT id FROM $t_emails WHERE email_addr = '$addr'");        
        }
       
        $selected_cats = explode(',', get_option('post_notification_selected_cats'));
       
        foreach($selected_cats as $cat){
            if(is_numeric($cat)){ //Security
                    if(!$wpdb->get_var("SELECT id FROM $t_cats WHERE id = $mid AND cat_id = $cat")){
                        $wpdb->query("INSERT INTO $t_cats (id, cat_id) VALUES($mid, $cat)");
                    }
            }
        }
    
}
NasheedsNow.com #2
Member since Mar 2009 · 1 post
Group memberships: Mitglieder
Show profile · Link to this post
Quote by syfr12 on 2009-01-06, 16:00:
give admin an option "Auto Subscribe When New User Registing" ,Choice "yes" ,the new user will auto subscribe


change :

1 in install.php add
add_option('post_notification_auto_subscribe', 'yes','Auto Subscribe when regist new user', 'no'); 
2 in admin_settings.php
  2.1 under line  <h4> <?php  _e('Technical', 'post_notification');  ?></h4>
      add:
    <tr class="alternate">
        <th style="text-align:right;padding-right:10px;"><?php _e('Auto Subscribe When New User Registing:', 'post_notification'); ?></th>
        <td>
            <select name="auto_subscribe" >
              <option value="no"  <?php  echo $auto_subscribeN; ?> > <?php  _e('No', 'post_notification'); ?></option>
              <option value="yes" <?php  echo $auto_subscribeY; ?> > <?php  _e('Yes', 'post_notification'); ?></option>
            </select>   
        </td>
    </tr> 

   2.2 in function post_notification_admin_sub()
      add:


    update_option('post_notification_auto_subscribe', $_POST['auto_subscribe']);

    if(get_option('post_notification_auto_subscribe') == 'yes') //rather have No
        $auto_subscribeY = $selected;
    else
        $auto_subscribeN = $selected;

3 in post_notification.php
  3.1 in  function post_notification_gui_init() add:
      add_action('user_register', 'post_notification_register'); 
  3.2 add function  post_notification_register
///  Auto Subscribe for new wordpress user registion
function post_notification_register($user_id) {
    global $wpdb;     
   
    if ($user_id == 0 ) { $user_id = get_userdatabylogin($_POST['user_login']); }
  
    $auto_subscribe =  get_option('post_notification_auto_subscribe') ;
    if ($auto_subscribe == "no") { return; }
   
    if (0 == $user_id) { $user_id = (int) func_get_arg( 0 ); }
    if (0 == $user_id) { return; }      
      
        $t_emails = $wpdb->prefix . 'post_notification_emails';
        $t_cats = $wpdb->prefix . 'post_notification_cats';
       
          
        $user = get_userdata($user_id);
        $addr = $user->user_email ;
        $gets_mail = 1;
        $now = post_notification_date2mysql();
       
        $mid = $wpdb->get_var("SELECT id FROM $t_emails WHERE email_addr = '$addr'");
        if (!$mid) {
            $wpdb->query(
                    "INSERT " . $t_emails .
                    " (email_addr, gets_mail, last_modified, date_subscribed) " .
                    " VALUES ('$addr', '$gets_mail', '$now', '$now')");       
            $mid = $wpdb->get_var("SELECT id FROM $t_emails WHERE email_addr = '$addr'");        
        }
       
        $selected_cats = explode(',', get_option('post_notification_selected_cats'));
       
        foreach($selected_cats as $cat){
            if(is_numeric($cat)){ //Security
                    if(!$wpdb->get_var("SELECT id FROM $t_cats WHERE id = $mid AND cat_id = $cat")){
                        $wpdb->query("INSERT INTO $t_cats (id, cat_id) VALUES($mid, $cat)");
                    }
            }
        }
    
}

Thank you so much! This is just what I was looking for and it worked  :-D ! Cheers.

Hmm, it makes me wonder whether it is possible to autosubscribe existing registered users using a mod? Thanks again!
Morty (Administrator) #3
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
I just added this to 1.x branch. It'll be in the next release.
peterve #4
Member since Sep 2008 · 20 posts
Group memberships: Mitglieder
Show profile · Link to this post
I like this feature a lot, however it would be nice to see a checkbox in the registration page to allow the user to subscribe when he or she registers
Do you think that would be possible ?
Morty (Administrator) #5
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Where is the sense in that?
Morty (Administrator) #6
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
In reply to post #2
Quote by NasheedsNow.com on 2009-03-11, 07:16:
Hmm, it makes me wonder whether it is possible to autosubscribe existing registered users using a mod? Thanks again!

You can export your subscribers and then use the management tab.
sohalm #7
Member since Mar 2010 · 2 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: auto subscribe not working
I am new to this plugin and think it is a fantastic time saver.

I have set "Add user to PN when registering to WP:" to "yes". However, this does not seem to work.
Do I need to add the code in this thread to make this work?

I am on WP 2.9.2, and am using register plus

Thanks
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