dongwujie7477 2016-07-15 10:13
浏览 45
已采纳

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

im working on statestic wordpress plugin that allow the admin to get all the contributions of every contributor on the site daily, monthly .. etc, it have 3 pages, one contain a search button to search for username, the second page will contain the results of the name searched in first page, the 3rd page will contain a detailed report on every contribution durging a laps of time i have create my plugin this way inside the plugin folder there is: 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/style.css includes/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>

includes/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>

includes/contributions.php

for now i didnt create function to do the job, my only problem is that when i click on submit to be redirected to stats page i get this error

wordpress You do not have sufficient permissions to access this page.

  • 写回答

2条回答 默认 最新

  • douliaodun9153 2016-07-18 11:52
    关注

    You don't have registered stats page in admin_pages.

    Solution

    Adjust your code in includes/whatefty-stat-display.php to something like this:

    <?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>
    

    The main changes are in:

    • removing action attribute from <form>
    • including results (stats) page in same php file, in case there is $_POST['wathefty_submit'] set

    Note that name attribute of submit button was changed.

    Optionally, you could enclose the form in else branch, so the form wouldn't be displayed on stats page.

    Alternative Solution

    Alternative solution could be adding another menu page with add_menu_page function and including the second file there, but it doesn't seems to me right to have one menu page registered for form and other for results.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我的R语言提示去除连锁不平衡时clump_data报错,图片以下所示,卡了好几天了,苦恼不知道如何解决,有人帮我看看怎么解决吗?
  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序