سلام
من همه مراحل رو مو به مو انجام دادم ، اما در قسمت نمایش همانند فایل ضمیمه متاسفانه مقداری که در کیف پول وارد کردم نمایش داده نمیشه! =>’ یک افزونه با نام user نوشتم و مقادیر رو در فایل هاش ساماندهی کردم ، چنین دایرکتوری هایی ایجاد کردم:
فایل اصلی افزونه با نام (user):
* inc(پوشه)
* menus.php
* user.php
محتویات پوشه inc:
* edit(پوشه)
* users.php
محتویات پوشه edit:
* edit.php
/// محتویات کد ها///
فایل کد user.php:
<?php
/*
Plugin Name: افزونه مدیریت کاربران
Plugin URI: https://sarzamin-site.ir
Description: افزونه ای جهت مدیریت کاربران در وردپرس
Requires at least: WP 4.0.0
Tested up to: WP 4.8.2
Author: صالح عطاری
Author URI: mailto:salehattari1386@gmail.com
Version: 1.0.0
*/
define('WP_USER_DIR' , plugin_dir_path(__FILE__)) ;
define('WP_USER_URL' , plugin_dir_url(__FILE__)) ;
define('WP_USER_INC' , WP_USER_DIR. '/inc/') ;
define('WP_USER_TPL' , WP_USER_DIR. "//") ;
if(is_admin()){
include WP_USER_TPL.'menus.php';
}
فایل کد menus.php:
<?php
add_action('admin_menu' , 'wp_user_register_menus') ;
function wp_user_register_menus(){
add_menu_page(
'تنظیمات افزونه مدیریت کاربران' ,
'مدیریت کاربران' ,
'manage_options' ,
'wp_user_register_menus' ,
'wp_user_main_menu_handler'
);
}
function wp_user_main_menu_handler(){
global $wpdb;
$userID = intval($_GET['id']);
if(isset($_GET['action']) && $_GET['action'] == 'edit')
{
if(isset($_POST['saveuserinfo'])){
$mobile = $_POST['mobile'];
$wallet = $_POST['wallet'];
if(!empty($mobile)){
update_user_meta($userID , 'mobile' , $mobile);
}
if(!empty($wallet)){
update_user_meta($userID , 'wallet' , $wallet);
}
}
$mobile= get_user_meta($userID , 'mobile' , true);
$wallet= get_user_meta($userID , 'wallet' , true);
include WP_USER_INC.'edit/edit.php';
return;
}
$users = $wpdb->get_results("SELECT ID,user_email,display_name FROM {$wpdb->users}");
include WP_USER_INC.'users.php';
}
فایل کد users.php:
<div class="wrap">
<h1>کاربران ویژه</h1>
<table class="widefat">
<thead>
<tr>
<th>شناسه</th>
<th>نام کامل</th>
<th>ایمیل</th>
<th>شماره همراه</th>
<th>کیف پول</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
<?php foreach($users as $user): ?>
<tr>
<td> <?php echo $user->ID; ?> </td>
<td> <?php echo $user->display_name; ?> </td>
<td> <?php echo $user->user_email; ?> </td>
<td> <?php echo get_user_meta($user->ID, 'mobile' , true); ?> </td>
<td> <?php get_user_meta($user->ID, 'wallet' , true); ?> </td>
<td>
<a href="<?php echo add_query_arg(['action'=>'edit' , 'id'=>$user -> ID]); ?>">
<span class="dashicons dashicons-edit"></span>
</a>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
فایل کد edit.php:
<div class="wrap">
<h1>ویرایش اطلاعات کاربر</h1>
<form action="" method="post">
<table class="form-table">
<tr valign="top">
<th scope="row"> شماره همراه </th>
<td>
<input type="text" name="mobile" value="<?php echo $mobile;?>"/></td>
</tr>
<tr valign="top">
<th scope="row"> کیف پول </th>
<td>
<input type="text" name="wallet" value="<?php echo $wallet;?>"/></td>
</tr>
</tr>
<tr valign="top">
<th scope="row"></th>
<td>
<button class="button" type="submit" name="saveuserinfo">ذخیره سازی اطلاعات</button>
</tr>
</table>
</form>
</div>
لطفا بگید ایراد کارم از کجاست؟