Email Notice Script Problem

I’m having issue with this php file. As it load a list of members from a DB. Then we are able to select single, multiples or all members to send a notice. The issue is it appears to send the message to all members, but only around half received the message. Once we go back to the notice sent it shows only half of the members been selected, when all were selected. Any help will be appreciated.

[php]

<?php /** * General settings administration panel. * * @package WordPress * @subpackage Administration */ /** WordPress Administration Bootstrap */ require_once('./admin.php'); if ( ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); if($_GET['method']=='edit'){ $title = __('Edit Member Notice'); } else { $title = __('Member Notice'); } $parent_file = 'membernotice.php'; /* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */ $timezone_format = _x('Y-m-d G:i:s', 'timezone date format'); /** * Display JavaScript on the page. * * @package WordPress * @subpackage General_Settings_Panel */ if(isset($_POST['submit'])) { $user_id=""; if(is_array($_POST['users'])) { $user_id="|".implode("|",$_POST['users'])."|"; } else { $user_id= $_POST['users']; } if(!isset($_POST['id'])) { $insert=$wpdb->query("INSERT INTO wp_membernotice (user_id, ntitle, ndescription, show_id) VALUES ('".$user_id."', '".$_POST['ntitle']."', '".$_POST['ndescription']."', '".$user_id."')"); echo ""; $msg="Notice Successfully Added"; } else{ $sql="UPDATE wp_membernotice SET user_id='".$user_id."', ntitle='".$_POST['ntitle']."', ndescription='".$_POST['ndescription']."' WHERE id='".$_POST['id']."'"; $insert=$wpdb->query($sql); $msg="Notice Successfully Updated"; } foreach($_POST['users'] as $u_id) { $admin_email = get_option('admin_email'); $email = $wpdb->get_row("SELECT * FROM wp_users WHERE ID='".$u_id."'"); $to = $email->user_email; $subject = "Notice from ourwebsite.com"; $message="Hello ".get_user_meta($email->ID,'first_name',true)."
"; $message.="

You have a new notice posted to your My Profile / Member Page. Please log in to ourwebsite.com


"; $message.="Your Support Team
"; $message.="ourwebsite.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers.= "From: " ."your company ". $admin_email . "\n" . "Return-Path: " . $admin_email . "\n" . "Reply-To: " ."Your Comapny ". "Your Company ".$admin_email . "\n"; mail($to, $subject, $message, $headers); } } if(isset($_GET['id'])){ $sidebar_row = $wpdb->get_row("SELECT * FROM wp_membernotice where id=".$_GET['id']); $sidebar_title="Edit Notice"; } else{$sidebar_title="Add Notice";} if($_GET['method']=='del' && isset($_GET['id'])){ $delete = $wpdb->query("delete from wp_membernotice where id=".$_GET['id']); $msg="Notice Successfully Deleted"; } if($_GET['method']=='del' && is_array($_POST['slide'])){ $sid=implode(',',$_POST['slide']); $delete = $wpdb->query("delete from wp_vendor where id in(".$sid.")"); $msg="Notices Successfully Deleted"; } include('./admin-header.php'); ?> .show_error{ color:red; display : none; }
<?php screen_icon(); ?>

<?php echo esc_html( $title ); ?>

<?php $document = $wpdb->get_row("SELECT * FROM wp_membernotice WHERE id='".$_GET['id']."'"); ?>
<?php if(isset($_GET['method']) && ($_GET['method']=='save' || $_GET['method']=='edit')){?>
<?php echo $error;?>
Notice Title
Please Enter Notice Title
Notice Description
<?php the_editor($sidebar_row->ndescription, 'ndescription','',false,2);?>
Select Subscribers <?php $user_list=$wpdb->get_results("SELECT * FROM wp_users ORDER BY user_login ASC"); $sort=array(); $i=0; foreach($user_list as $list){
                    $id=$list->ID;
                    
                    if(!get_user_meta($list->ID,'first_name',true))
                    {
                        $sort[$i][0]= trim($list->user_login," ");
                    } 
                    else 
                    {
                    $sort[$i][0]= trim(get_user_meta($list->ID,'last_name',true)," ").'&nbsp;'.trim(get_user_meta($list->ID,'first_name',true)," ");
                    }
                    //$sort[$i][0]=get_user_meta($id,'last_name',true);
                    $sort[$i][1]=$id;
                    $sort[$i][2]=0;
                    $checked=explode("|",$document->user_id); 
                    $sort[$i][3]=$list->user_login;
                    for($f=1;$f<count($checked);$f++)
                    {
                        if($id==$checked[$f])
                        {
                            $sort[$i][2]=1;
                        }
                        
                    }
                    
                    
                    $i++;
                  
                }
                
                sort($sort);
                
                for($j=0;$j<count($sort);$j++)
                {
                ?>
                <span class="inline_listings">
          <input  id="checklist<?php $i;?>" type="checkbox" name="users[]" value="<?php echo $sort[$j][1]; ?>"  <?php if($sort[$j][2]==1) { echo "checked='checked'"; }  ?>>
          <?php echo $sort[$j][0] ?></span>
                <?php
                }
                ?>
          
        </td>
      </tr>
        <tr>
        <th>&nbsp;</th>
        <td><input type="checkbox" name="noticecheckall" id='notice-membernotice' value="" /> <strong>Check All / Uncheck All</strong></td>
      </tr>  
      </tbody>
  </table>
  <p class="submit">
    <?php if($_GET['method']=='edit' && isset($_GET['id'])){?>
    <input type="submit" value="Edit Notice" name="submit" class="button">
    <input type="hidden" name="id" id="id" value="<?php echo $_GET['id'];?>" />
    <?php }else{ ?>
    <input type="submit" value="Save Notice" name="submit" class="button">
    <?php } ?>
    <input type="button" value="Cancel" onclick="window.location.href='membernotice.php';" name="cancelside" class="button">
  </p>
</form>
<?php }else{ ?>
<h2>Manage Notice<a title="" target="_self" href="membernotice.php?method=save" rel="" class="button add-new-h2">Add New</a></h2>
<form name="delsidebar" action="membernotice.php?method=del" method="post">
  <div class="tablenav">
    <div class="alignleft actions">
      <input type="submit" value="Delete" name="deletegal" class="button"/>
      <span style="color:red;font-weight:bold;"><?php echo $msg;?></span> </div>
  </div>
  <table class="widefat">
    <thead>
      <tr>
        <th class="check-column"><input type="checkbox" value="checkboxall" id="checkboxall" name="checkboxall"></th>
        <th>S.No.</th>
        <th>Notice Title</th>
        <th>Notice Description</th>
        <th>Users</th>
        <th>Added On</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <th class="check-column"><input type="checkbox" value="checkboxall" id="checkboxall" name="checkboxall"></th>
        <th>S.No.</th>
        <th>Notice Title</th>
        <th>Notice Description</th>
        <th>Users</th>
        <th>Added On</th>
      </tr>
    </tfoot>
    <tbody>
      <?php
            $i=1;
        $sidebar = $wpdb->get_results("SELECT * FROM wp_membernotice  order by ntitle");
            foreach($sidebar as $sdata){
            ?>
      <tr class="alternate">
        <th class="check-column"><input type="checkbox" id="checklist4" value="<?php echo $sdata->id;?>" name="slide[]"></th>
        <td><?php echo $i;?></td>
        <td><a title="" href="membernotice.php?method=edit&id=<?php echo $sdata->id;?>" class="row-title"><?php echo $sdata->ntitle;?></a>
          <div class="row-actions"> <span class="edit"><a title="" target="_self" href="membernotice.php?method=edit&id=<?php echo $sdata->id;?>" rel="" class="wpco">Edit</a> |</span> <span class="delete"><a title="" target="_self" href="membernotice.php?method=del&id=<?php echo $sdata->id;?>" onclick="if (!confirm('Are you sure you want to permanently remove this Notice?')) { return false; }" rel="" class="submitdelete">Delete</a></span> </div></td>
        <td><?php
                echo $sdata->ndescription;
            ?></td>
        <td><?php
                    $userdata = explode("|",$sdata->user_id);
                    $count = count($userdata);
                    $newcount = $count-2;
                    $slice = array_slice($userdata,1,$newcount);
                    $datauser=implode(",",$slice);
                    $select=$wpdb->get_results("SELECT * FROM wp_users WHERE ID in (".$datauser.")");
                    //print_r($slice);
                    $count_sel =0;
                    foreach($select as $sel)
                    {
                        if($count_sel==0) {
                            echo get_user_meta($sel->ID,'first_name',true);
                        }
                        else {
                            echo ", ".get_user_meta($sel->ID,'first_name',true);
                        }
                    $count_sel++;
                    }
                    ?></td>
                     <td><?php
                  $ndate = explode("-",$sdata->created_on);
                  $day = explode (" ",$ndate[2]);
                  $newdate=array($day[0],$ndate[1],$ndate[0]);
                  echo implode("-",$newdate);                        
                    ?></td>
      </tr>
      <?php $i++;} ?>
    </tbody>
  </table>
</form>
<?php } ?>
<?php include('./admin-footer.php') ?>

[/php]

Maybe try the wordpress forum this is a wordpress problem ?

Also, you should check with your email system. Most do not allow sending emails to large numbers of addresses. A lot of services limit the number of emails sent to a set number. You may have to have the limit upped to a higher number. The reason email systems do this is to cut down on SPAMMER’s… One simple way to test this, is to see how many are actually sent out. If the number is exactly the same every time you email, then there is a limit set to that number.

Good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service