Skip to content

Instantly share code, notes, and snippets.

View raftaar1191's full-sized avatar
🏠
Working from home

Deepak Gupta raftaar1191

🏠
Working from home
View GitHub Profile
@raftaar1191
raftaar1191 / functions.php
Created April 19, 2024 15:04
Only show the admin user list when deleting a user and assing his content
function delete_user_account( $query_args ) {
// Use this array to specify multiple roles to show in dropdown
$query_args['role__in'] = array( 'administrator' );
// Unset the 'who' as this defaults to the 'author' role
unset( $query_args['who'] );
return $query_args;
}
@raftaar1191
raftaar1191 / pretty-link-creation.php
Created April 1, 2024 05:50 — forked from DumahX/pretty-link-creation.php
Creating new pretty links through code
@raftaar1191
raftaar1191 / functions.php
Created October 18, 2023 07:02
How can I limit the activity feed to show 10 posts, then the load more appears?
function limit_activities_displayed( $retval ) {
$isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile"));
if ($isMob) {
$retval['per_page'] = 15;
}
else {
$retval['per_page'] = 5;
}
return $retval;
}
@raftaar1191
raftaar1191 / functions.php
Created October 12, 2023 08:28
Fix for Not able to comment on Other User Activity Post in PHP version 8.2
remove_action( 'bp_activity_after_email_content', 'bb_gif_activity_after_email_content' );
@raftaar1191
raftaar1191 / functions.php
Created October 11, 2023 08:53
Change/Update place holder of the login input of BuddyBoss login page
/**
* Update the place holder into the login page
*/
function acrosswp_custom_bb_login_head_callback() {
?>
<script>
jQuery( document ).ready( function ($) {
jQuery( 'form#loginform #user_login' ).attr( 'placeholder', "Custom Email" );
});
@raftaar1191
raftaar1191 / functions.php
Created October 4, 2023 06:56
Do not allow activity to get posted without any Media
/**
* Add content into the post
*/
function acrosswp_nouveau_ajax_post_update_custom() {
if ( ! is_user_logged_in() || empty( $_POST['_wpnonce_post_update'] ) || ! wp_verify_nonce( $_POST['_wpnonce_post_update'], 'post_update' ) ) {
wp_send_json_error();
}
// check activity toolbar options if one of them is set, activity can be empty.
@raftaar1191
raftaar1191 / courses-courses.php
Last active September 6, 2023 12:45
Courses page in Group show the 1 courses in listing format not like a single page courses format
<?php
$ld_group_id = bp_ld_sync( 'buddypress' )->helpers->getLearndashGroupId( bp_get_current_group_id() );
if ( $ld_group_id ) {
$post_label_prefix = 'group';
$meta = learndash_get_setting( $ld_group_id );
$post_price_type = ( isset( $meta[ $post_label_prefix . '_price_type' ] ) ) ? $meta[ $post_label_prefix . '_price_type' ] : '';
$post_price = ( isset( $meta[ $post_label_prefix . '_price' ] ) ) ? $meta[ $post_label_prefix . '_price' ] : '';
// format the Course price to be proper XXX.YY no leading dollar signs or other values.
@raftaar1191
raftaar1191 / functions.php
Created September 5, 2023 15:46
Fix BuddyBoss Platform V 2.4.11 Activity issue
/**
* Remove the new filter that is been added into BuddyPress 2.4.11
*/
function awp_bp_init_bb_platform_issue() {
remove_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_scope', 10 );
}
add_action( 'bp_init', 'awp_bp_init_bb_platform_issue' );
@raftaar1191
raftaar1191 / functions.php
Created September 5, 2023 09:27
Filter to allow shortcode to render inside forms discussion
/**
* Filter to run the shortcode into the formds
*/
function bbp_get_topic_content_callback( $content ) {
return do_shortcode( $content );
}
add_filter( 'bbp_get_topic_content', 'bbp_get_topic_content_callback', 100000 );
@raftaar1191
raftaar1191 / functions.php
Created August 31, 2023 19:55
Patch to fixed the Group menu issue that came in version BB theme version: 2.4.01
/**
* Temp patch for Group Menu issue in the BB theme version: 2.4.01
*/
function awp_add_boss_menu_js_functions() {
if(
function_exists( 'bp_get_group_current_admin_tab' )
&& in_array( bp_get_group_current_admin_tab(), array( 'edit-details', 'group-settings', 'group-avatar', 'group-cover-image', 'manage-members', 'membership-requests', 'delete-group', 'forum' ), true )
) {
?>