完全阻止订阅者在wordpress上的后端

时间:2014-01-18 16:39:23

标签: php wordpress web-services web-applications

我在wordpres上设计我的网站。我想完全从后端窃取订阅者。我用一些插件管理得很少。但问题是,当他们发布某些内容时,他们会在帖子旁边显示他们的显示名称,当他们点击他们的显示名称时,他们会被重定向到后端的个人资料页面。如果用户点击显示名称并将其完全阻止,请帮助我如何将订阅者重定向到自定义个人资料页面。

1 个答案:

答案 0 :(得分:1)

Christopher Davies(chrisguitarguy)有一个很棒的插件可以满足您的要求:

<?php
/*
Plugin Name: No Dashboard
Description: Don't allow subscribers to access to the wp-dashboard
Author: Christopher Davis
Plugin URI: https://gist.github.com/chrisguitarguy/1877504
*/

register_activation_hook( __FILE__, 'wpse43054_activation' );
function wpse43054_activation()
{
    $role = get_role( 'subscriber' );
    if( $role ) $role->remove_cap( 'read' );
}

register_deactivation_hook( __FILE__, 'wpse43054_deactivation' );
function wpse43054_deactivation()
{
    $role = get_role( 'subscriber' );
    if( $role ) $role->add_cap( 'read' );
}

add_action( 'init', 'wpse43054_maybe_redirect' );
function wpse43054_maybe_redirect()
{
    if( is_admin() && ! current_user_can( 'read' ) )
    {
        wp_redirect( home_url(), 302 );
        exit();
    }
}

add_filter( 'get_user_metadata', 'wpse43054_hijack_admin_bar', 10, 3 );
function wpse43054_hijack_admin_bar( $null, $user_id, $key )
{
    if( 'show_admin_bar_front' != $key ) return null;
    if( ! current_user_can( 'read' ) ) return 0;
    return null;
}
相关问题