我对Buddypress有意见。我添加到用户配置文件的菜单链接
add_filter( 'wp_nav_menu_items', 'add_profile_bp_link_to_nav', 10, 2 );
function add_profile_bp_link_to_nav( $items, $args ) {
if ( is_user_logged_in() ) {
$items .= '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My profile', 'buddypress' ) . '</a> </li>';
}
return $items;
}然后我加一句
function force_login() {
is_user_logged_in() || auth_redirect();
}
add_action( 'parse_request', 'force_login', 1 );` 因为我希望将用户重定向到登录的wp-login.php。现在,当我点击my acount按钮时,我被重定向到wp-login.php。如何将用户重定向到login.php,并保持My acount按钮的正确操作?
发布于 2014-05-15 09:39:39
这对我很有效,只要把它放到你孩子的functions.php里就行了。
// stop guests from accessing the site, forces them to join
function bp_guest_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
// enter the slug or component conditional here
if(!is_user_logged_in()) { // not logged in user
wp_redirect( get_option('https://site.com/') . '/join/' );
} // user will be redirect to any link to want
}
}
add_filter('get_header','bp_guest_redirect',1); https://stackoverflow.com/questions/23479588
复制相似问题