wordpress插件重定向从页面到页面的权限错误

时间:2016-07-15 10:13:23

标签: php wordpress

我正在使用statestic wordpress插件,允许管理员每天,每月等获得网站上每个贡献者的所有贡献。它有3个页面,一个包含搜索按钮以搜索用户名,第二个页面将包含在第一页中搜索到的名称的结果,第3页将包含一个详细的报告,其中包含一段时间内的每个贡献 我在插件文件夹中以这种方式创建了我的插件: 的index.php

<?php
/**
* Plugin Name: wathefty
* Plugin URI: aaaaa
* Description:aaaaaaa .
* Version: aaaaa
* Author: aaaaa
* Author URI: aaaaa
**/

function wathefty_admin_actions() {
    add_menu_page('wathefty stat Display', 'wathefty', 'manage_options', 'wathefty-stat-Display','wathefty_stat_Display');

}

function wathefty_stat_Display(){include('includes/wathefty-stat-Display.php');
}
add_action('admin_menu', 'wathefty_admin_actions');



?>

风格/ style.css中 包括/ whatefty-STAT-Display.php的

<form action="admin.php?page=stats" method="post" >
<fieldset class="fieldset">
<legend class="legend">Search</legend>
<label class="label">Search by author name:</label>
<input class="input" type="text" name="click" />
<button class="button1" name="Submit" type="submit">Submit</button>
</fieldset>
</form>

包括/ stats.php

<table class="table">
<thead class="thead">
<tr class="tr">
<td class="td" rowspan="2">Post author</td>
<td class="td" rowspan="2">Author category</td>
<td class="td" colspan="4">Number of posts</td>
</tr>
<tr class="tr">
<td class="td">Daily</td>
<td class="td">Weekly</td>
<td class="td">Monthly</td>
<td class="td">Yearly</td>
</tr>
</thead>
<tbody class="tbody">
<tr class="tbody">
<td class="td">wathefty</td>
<td class="td">admin</td>
<td class="td"><a href="#">10</a></td>
<td class="td"><a href="#">42</a></td>
<td class="td"><a href="#">321</a></td>
<td class="td"><a href="#">1485</a></td>
</tr>
</tbody>
</table>

包括/ contributions.php

现在我没有创建功能来完成这项工作,我唯一的问题是,当我点击提交被重定向到统计页面时,我收到此错误

  

wordpress您没有足够的权限来访问此页面。

2 个答案:

答案 0 :(得分:0)

查看 wp_usermeta 表中的值,如下所示:

wp_capabilities 应该是:1:{s:13:“administrator”; s:1:“1”;}

wp_user_level 10

它会解决问题,如果你不能请给你用来打开你的插件面板的链接&gt;

答案 1 :(得分:0)

您还没有在admin_pages中注册统计信息页面。

解决方案

includes / whatefty-stat-display.php 中的代码调整为以下内容:

<?php 
if( isset( $_POST['wathefty_submit'] ) ) {
  include( dirname(__FILE__) . '/stats.php' );
}
?>

<form method="post" >
<fieldset class="fieldset">
<legend class="legend">Search</legend>
<label class="label">Search by author name:</label>
<input class="input" type="text" name="click" />
<button class="button1" name="wathefty_submit" type="submit">Submit</button>
</fieldset>
</form>

主要变化如下:

  • <form>
  • 删除操作属性
  • 在同一个php文件中包含结果(统计信息)页面,以防 $ _ POST [&#39; wathefty_submit&#39;] 设置

请注意,提交按钮的name属性已更改。

或者,您可以将表单括在 else 分支中,这样表单就不会显示在统计信息页面上。

替代解决方案

替代解决方案可能是添加另一个带有 add_menu_page 功能的菜单页面,并在那里添加第二个文件,但在我看来,为一个菜单页面注册表单并且其他结果