我有一个自定义页面,可以拉入用户,我正在使用一些分页。
如果我查看网站前端的页面,效果很好,但当我查看我制作的基本插件中管理区域内的网站时,它不起作用,我会收到一个权限错误“您没有足够的权限访问此页面”
这是下面的代码,我不知道为什么它不起作用,但如果有人有任何线索,我会非常感激,
谢谢
<?php
$total_users = count_users();
$total_users = $total_users[\'total_users\'];
$paged = get_query_var(\'paged\');
$number = 50;
?>
<?php
$args = array(
\'order\' => \'ASC\',
\'orderby\' => \'display_name\',
\'count_total\' => \'true\',
\'role\' => \'subscriber\',
\'offset\' => $paged ? ($paged) * $number : 0,
\'number\' => $number,
);?>
<?php
$blogusers = get_users($args);?>
<?php // Array of WP_User objects.
foreach ( $blogusers as $user ) {?>
<?php $userId = $user->ID;?>
<?php echo \'<input type="text" value="\' . esc_html( $user->display_name ) . \'">\';?>
<div id="content">
<h2>Completed Courses</h2>
<!-- COMPLIANCE-->
<?php
$post_args = array(
\'post_type\' => \'tribe_events\',
\'eventDisplay\'=>\'custom\',
\'start_date\' => date( \'Y-m-d H:i:s\', strtotime( \'-365 days\' ) ),
\'tax_query\' => array(
array(
\'taxonomy\' => \'tribe_events_cat\',
\'field\' => \'slug\',
\'terms\' => \'compliance\',
),
),
\'meta_query\' => array(
array(
\'key\' => \'associated_people\',
\'value\' => \'"\' . $userid . \'"\', // matches exaclty "123", not just 123. This prevents a match for "1234"
\'compare\' => \'LIKE\'
)
)
); ?>
<!-- MEMBERSHIP A -->
<?php if( rcp_is_active() && 2 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><a href="<?php the_permalink();?>"><?php the_title(); ?></a></td>
<td><?php the_field(\'cpd_credits\'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field(\'cpd_credits\');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP A -->
<?php $pl_args = array(
\'base\' => add_query_arg(\'paged\',\'%#%\'),
\'format\' => \'\',
\'total\' => floor($total_users / $number),
\'current\' => max(1, $paged),
);
// for ".../page/n"
if($GLOBALS[\'wp_rewrite\']->using_permalinks())
$pl_args[\'base\'] = user_trailingslashit(trailingslashit(get_pagenum_link(1)).\'page/%#%/\', \'paged\');
echo paginate_links($pl_args);?>