PHP code example of automattic / buddypress-hidden-profiles
1. Go to this page and download the library: Download automattic/buddypress-hidden-profiles library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
automattic / buddypress-hidden-profiles example snippets
add_filter(
'buddypress_hidden_profiles_is_hidden',
function( $is_hidden, $user_id ) {
// If another filter has already decided, respect that decision.
if ( is_bool( $is_hidden ) ) {
return $is_hidden;
}
// Example: Hide users with a specific meta value.
$should_hide = get_user_meta( $user_id, 'my_custom_meta', true );
if ( ! empty( $should_hide ) ) {
return true;
}
// Fall back to default check.
return null;
},
10,
2
);
add_filter(
'buddypress_hidden_profiles_additional_hidden_ids',
function( $additional_hidden ) {
global $wpdb;
// Example: Get users with a specific meta value in a single query.
$extra_hidden = $wpdb->get_col(
$wpdb->prepare(
"SELECT user_id FROM {$wpdb->usermeta}
WHERE meta_key = %s",
'my_custom_meta'
)
);
return array_merge( $additional_hidden, $extra_hidden );
}
);
wp cache delete bp_hidden_user_ids
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.