php [ProSites] - 如果只有bbp_participant功能,请过滤blogs_of_user以从列表中删除主要博客
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [ProSites] - 如果只有bbp_participant功能,请过滤blogs_of_user以从列表中删除主要博客相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: [ProSites] - Filter blogs_of_user
Plugin URI: https://premium.wpmudev.org/
Description: Filter blogs_of_user to remove main blog from list if only capability is bbp_participant
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
function wpmudev_pre_get_blogs_of_user( $user_blogs, $user_id, $all ) {
global $wpdb;
$keys = get_user_meta( $user_id );
if ( isset( $_REQUEST['cc_stripe_checkout'] ) ) {
if ( empty( $keys ) ) {
$user_blogs = array();
}
else {
if ( isset( $keys[ $wpdb->base_prefix . 'capabilities' ] ) ) {
$_main_site_caps = $keys[ $wpdb->base_prefix . 'capabilities' ];
$has_main_site_caps = false;
if ( ! empty( $_main_site_caps ) ) {
foreach ( $_main_site_caps as $main_site_cap ) {
$cap = maybe_unserialize( $main_site_cap );
unset( $cap['bbp_participant'] );
if ( ! empty( $cap ) ) {
$has_main_site_caps = true;
}
}
}
$keys = array_keys( $keys );
foreach ( $keys as $key ) {
if ( 'capabilities' !== substr( $key, -12 ) )
continue;
if ( $wpdb->base_prefix && 0 !== strpos( $key, $wpdb->base_prefix ) )
continue;
$site_id = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key );
if ( ! is_numeric( $site_id ) )
continue;
$has_main_site_caps = true;
}
if ( ! $has_main_site_caps ) {
$user_blogs = array();
}
}
}
}
return $user_blogs;
}
add_filter( 'pre_get_blogs_of_user', 'wpmudev_pre_get_blogs_of_user', 20, 3 );
以上是关于php [ProSites] - 如果只有bbp_participant功能,请过滤blogs_of_user以从列表中删除主要博客的主要内容,如果未能解决你的问题,请参考以下文章
HDOJ6217BBP Formula(数学公式)
hdu 6217 A BBP Formula 公式题
Javascript - 仅在 DOM 中可见 div 时播放音频
我如何获得指定的数组值
PHP:[Bug] 如果只有“error_reporting”可以隐藏或显示错误,为啥还存在“display_errors”?
php