Title: Why loading this code need login?
Last modified: August 22, 2016

---

# Why loading this code need login?

 *  [Hamed Takmil](https://wordpress.org/support/users/silvercover/)
 * (@silvercover)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/why-loading-this-code-need-login/)
 * I’ve written this piece of code and when I want to load it in WP admin I have
   to sign in again! what’s wrong?
 *     ```
       <?php
   
       function bedehkar_page() {
   
       	global $pagenow, $wpdb;
   
       	if($pagenow == 'admin.php' && $_GET['page'] == 'bedehkar' ){
   
       //		$R_delete = @$_GET['delete_id'];
       //
       //		if(is_numeric($R_delete)){
   
       //			$Check_Order = $wpdb->get_results("SELECT id FROM ".$wpdb->prefix."ticket_title WHERE id = '$R_delete'");
       //
       //			if($Check_Order){
       //
       //				foreach ($Check_Order as $row ) {
       //					$Get_ID = $row->id;
       //				}
       //
       //				$sql = $wpdb->query("DELETE FROM ".$wpdb->prefix."ticket_title WHERE id = '$R_delete'");
       //
       //				if($sql){
       //
       //					$sql = $wpdb->query("DELETE FROM ".$wpdb->prefix."ticket_body WHERE title_id = '$R_delete'");
       //
       //					if($sql){
       //						$msg[] = "تیکت مورد نظر شما با موفقیت کامل حذف گردید";
       //					}
       //
       //				}
       //
       //			}
       //
       //		}
       //
       		//======================================================================
   
       		$Limit = "40";
   
       		$R_page     = @$_GET['my-page'];
       		$R_w_search = @$_POST['w_search'];
       		$R_close    = @$_REQUEST['close'];
   
       		$records = $wpdb->get_results("SELECT u.ID
       											  FROM ".$wpdb->prefix."users AS u
   
       											  LEFT JOIN ".$wpdb->prefix."usermeta AS m
       											  ON u.ID = m.user_id
   
       											  WHERE (u.user_email LIKE '%$R_w_search%') and m.meta_key='balance' and m.meta_value < 0");
       		if($records){
   
       			$R_this_page = $R_page;
       			$Total_Rec   = $wpdb->num_rows;
       			$Suffix      = "./admin.php?page=bedehkar&my-page=";
   
       			list($R_this_page, $Total_page, $Limitvalue) = GetPageNumber ($R_this_page, $Total_Rec, $Limit);
   
       			$Page_NeBa = ($Total_page != "1")? PageListNextBack ($R_this_page, $Total_page, $Limit, $Total_Rec, $Suffix) : "";
   
       		}
   
       		//Select Record
       		//======================================================================
   
       		$records = $wpdb->get_results("SELECT *
       											  FROM ".$wpdb->prefix."users AS u
   
       											  LEFT JOIN ".$wpdb->prefix."usermeta AS m
       											  ON u.ID = m.user_id
   
       											  WHERE (u.user_email LIKE '%$R_w_search%') and m.meta_key='balance' and m.meta_value < 0
                                                                                                 ORDER BY convert( m.meta_value, decimal ) asc
       											  LIMIT $Limitvalue, $Limit");
   
       		$My_Record = "";
   
       		if($records){
   
                   $C = $Limitvalue;
   
       			foreach ( $records as $record ) {
   
                       $C++;
   
       				$V_id              = $record->id;
       				$V_user_id         = $record->user_id;
       				$V_user_email      = $record->user_email;
       				$V_user_balance    = $record->meta_value;
   
       				$V_last_name       = get_the_author_meta( 'last_name', $V_user_id ); //Get name from wordpress db
   
       				//===================================================
   
       				//===================================================
   
       				$Class = ($C % 2 == 0)? 'td_02' : 'td_01';
   
       				//===================================================
   
       				$My_Record .= "\n
       				 			   <tr class='$Class'>
   
       							   		<td height='35' align='center'>$C</td>
   
       									<td height='35' class='title column-title'>
                                               <span>$V_last_name</span>
       									</td>
   
       									<td height='35' class='title column-title'>
                                               <span><a href=\"./user-edit.php?user_id=$V_user_id\" target=\"_blank\">$V_user_email</a></span>
       									</td>
   
       									<td height='35' class='title column-title'>
                                               <span>$V_user_balance</span>
       									</td>
   
                             		   </tr>
       							   \n";
   
       			}
   
       		}
       		//========================================================================
   
       ?>		
   
          <style type="text/css">
   
       	   a {
       			text-decoration: none;
       	   }
   
       	   .title {
       			font: bold normal 12px Tahoma, Geneva, sans-serif;
       			color: #F00;
       	   }
   
       	   .star {
       			color: #F00;
       	   }
   
       	   .normal {
       	       font: normal 12px Tahoma, Geneva, sans-serif;
       	       text-decoration: none;
       	       color: #00F;
       	   }
   
       	   .blue {
       	       color: #00F;
       	   }
   
       	   .green {
       	       color: #090;
       	   }
   
       	   .red {
       	       color: #F00;
       	   }
   
       	   .row-actions {
       	       font: normal 11px Tahoma, Geneva, sans-serif;
       	       margin-top: 10px;
       	   }
   
       	   .msg {
       	       padding: 5px;
       	       margin-top: 10px;
       	       margin-bottom: 10px;
       	       border: 1px solid #FFAEAE;
       	       background: #FFECEC;
       	   }
   
       	   .wp-list-table thead {
       		   background: #CCC;
       	   }
   
       	   .td_01 {
       			background: #F9F9F9;
       	   }
   
       	   .td_02 {
       			background: #FFF;
       	   }
   
       	   .link-box {
       		   margin: 0px;
       	   }
   
       	   .link-box .item {
       			float: right;
       			width: 60px;
       			height: 60px;
       			border: 1px solid #D1D1D1;
       			margin-bottom: 10px;
       			margin-left: 30px;
       			display:block;
       			color:#fff;
       	   }
   
          	   .link-box .item span{
       			float: left;
       			border: 1px solid linen;
       			display:block;
       			border-radius:5px;
       			background:none repeat scroll 0 0 brown;
       			color:#ffff;
       			margin:3px;
       			padding:1px;
       	   }	   
   
       	   .link-box .select-item {
       	   		border: 1px solid #F00;
       	   }
   
       	   .link-box .link_06 {
       		   background: url(<?php bloginfo('template_url'); ?>/images/list-icon.png) no-repeat -427px -2px;
       	   }
   
       	   .link-box .link_07 {
       		   background: url(<?php bloginfo('template_url'); ?>/images/list-icon.png) no-repeat -513px -2px;
       	   }
   
           </style>
   
       	<table width="100%" border="0" cellspacing="1" cellpadding="1">
   
                 <tr>
                   <td height="25">
                       <?php if(!empty($msg)){ ?>
        					 <div class="msg">
                       	<?php
                           	foreach ($msg as $v => $k){
               					echo $k."<br />";
               				}
                      		?>
                       	</div>
                   	<?php } ?>
                   </td>
                 </tr>
   
                 <form action="admin.php?page=bedehkar" method="post">
                 <tr>
                   <td height="10">
                   	<input name="w_search" type="text" value="<?php echo $R_w_search; ?>" />
                       <input name="search-btn" type="submit" value="*جستجو" class="button-primary" />
                   </td>
                 </tr>
                 </form>
   
                 <tr>
                   <td height="40">
   
                       <table class="wp-list-table widefat fixed posts" cellspacing="0">
                         <thead>
                             <tr>
   
                             	<td height="40" width="40" align="center"><b>ردیف</b></td>
   
                               <td width="120"><b>نام کاربر</b></td>
   
                               <td width="170"><b>ایمیل</b></td>
   
                               <td width="150"><b>موجودی</b></td>
   
                             </tr>
                          </thead>
   
                          <tbody id="the-list">
                             <?php echo $My_Record; ?>
                          </tbody>
   
                       </table>
   
                   </td>
                 </tr>
   
                 <?php if($Total_page != "1"){ ?>
                 <tr>
                 	<td height="45" style="padding:2px 0px 0px 5px;" align="left"><?php echo  $Page_NeBa; ?></td>
                 </tr>
               <?php  } ?>
   
           </table>
   
       <?php 
   
       	}
   
       }
   
       ?>
       ```
   
 * GetPageNumber and PageListNextBack are simple functions for pagination.

The topic ‘Why loading this code need login?’ is closed to new replies.

## Tags

 * [login](https://wordpress.org/support/topic-tag/login/)

 * 0 replies
 * 1 participant
 * Last reply from: [Hamed Takmil](https://wordpress.org/support/users/silvercover/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/why-loading-this-code-need-login/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
