Skip to content

Instantly share code, notes, and snippets.

View raviousprime's full-sized avatar
🙂
I may be slow to respond.

Ravi Sharma raviousprime

🙂
I may be slow to respond.
  • cosmic coders pvt. ltd.
  • Mohali Punjab
View GitHub Profile
@raviousprime
raviousprime / role-based-default-cover.php
Last active April 12, 2024 18:53
Role based default cover-image for users
<?php
// Capability based
/**
* Set different default background images based on user roles
*
* @param array $settings
*
* @return array
*/
@raviousprime
raviousprime / mpp-groups-gallery-nav-count.php
Created March 29, 2024 10:14
It shows gallery count with Gallery nav menu for groups in BuddyPress Nouveau template pack
@raviousprime
raviousprime / post-list-sc.php
Created March 21, 2021 18:24
Plugin for listing posts using shortcode [bd_post_lists cat=category_slug numberposts=6]
<?php
/**
* Plugin Name: Post List Shortcode
* Plugin URI: https://buddydev.com/
* Description: List posts from a category.
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: BuddyDev
* Author URI: https://buddydev.com/
<?php
/**
* Modify profile visibility
*
* @param bool $can_see Weather can see or not.
* @param int $user_id Displayed user id.
* @param int $visitor_id Visitor id.
*
* @return bool
@raviousprime
raviousprime / bp-circles-affiliate-members.php
Last active April 7, 2020 08:28
List members who add displayed user in his circle
<?php
/**
* Class BuddyCircles_Affiliate_Users
*/
class BuddyCircles_Affiliate_Users {
/**
* Affiliate user list.
*
* @var array
@raviousprime
raviousprime / posts.php
Created January 8, 2020 10:33
Modify buddyblog loop with theme loop
<?php
<?php if ( buddyblog_user_has_posted() ): ?>
<?php
//let us build the post query
if ( bp_is_my_profile() || is_super_admin() ) {
$status = 'any';
} else {
$status = 'publish';
}
@raviousprime
raviousprime / bbpress-roles-based-forum-access.php
Created January 7, 2020 07:07
Hide some forum from user based on roles
<?php
/**
* Get excluded forum ids.
*
* @return array
*/
function buddydev_get_excluded_forum_ids() {
return array( 552, 554 ); // Replace by yours forum ids.
}
@raviousprime
raviousprime / role-based-restrict-other-user-profile.php
Created October 17, 2019 05:10
Restricted user to view other profile based on his role
<?php
add_action( 'bp_template_redirect', function() {
if ( bp_is_user() && is_user_logged_in() && ! bp_is_my_profile() ) {
$user = wp_get_current_user();
$restricted_roles = array( 'editor' ); // Replace by your roles.
$has_restricted_role = array_intersect( $restricted_roles, $user->roles );
if ( ! empty( $has_restricted_role ) ) {
$message = sprintf( 'You are not allowed to view %s profile', bp_core_get_user_displayname( bp_displayed_user_id() ) );
@raviousprime
raviousprime / bulk-group-user-join.php
Created August 29, 2019 14:10
Bulk join user of certain role to BuddyPress group when created
<?php
add_action( 'groups_create_group', function( $group_id ) {
// Get users of certain roles.
$user_ids = get_users(
array(
'role' => array( 'subscriber' ),
'fields' => 'ID',
)