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 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 )
) {
?>
@raftaar1191
raftaar1191 / functions.php
Last active August 30, 2023 14:30
Redirect user to cart page when they login
/**
* WordPress function for redirecting users on login based on user role
*/
function awp_login_redirect_callback( $url, $request, $user ) {
/*
* Add your custom url
*/
$url = home_url( '/cart/' );
return $url;
@raftaar1191
raftaar1191 / functions.php
Last active August 7, 2023 12:42
Add text on the user profile page after the nickname is displayed
/**
* Print custom text on the profile page after the nickname
*/
function awp_bp_before_member_header_meta_callback() {
echo "Custom Text";
}
add_action( 'bp_before_member_header_meta', 'awp_bp_before_member_header_meta_callback' );
@raftaar1191
raftaar1191 / functions.php
Created June 7, 2023 15:47
Change the default template of page and post to something else
/**
* Change the default template to elementor_header_footer for new page and post
*/
function bb_rest_set_default_page_template( $data, $post ) {
if (
0 != count( get_page_templates( $post ) )
&& get_option( 'page_for_posts' ) != $post->ID
&& '' == $data->data['template']
) {
@raftaar1191
raftaar1191 / functions.php
Created May 15, 2023 11:19
Remove gutenbur and wp-editor from Specific page
function use_block_editor_for_post_disable_gutenberg( $can_edit, $post ) {
if( $post->ID == '247' ) {
return false;
}
return true;
}
add_filter( 'use_block_editor_for_post', 'use_block_editor_for_post_disable_gutenberg', 10, 2 );
@raftaar1191
raftaar1191 / functions.php
Last active May 15, 2023 10:55
Add custom link into the User Profile Menu of BuddyBoss
function bp_member_options_nav_custom_link() {
?>
<li id="custom-link-li" class="bp-personal-tab">
<a href="/members/admin/invites/" id="custom-link" class="">
<div class="bb-single-nav-item-point">Custom Text</div>
</a>
</li>
<?php
}
add_action( 'bp_member_options_nav', 'bp_member_options_nav_custom_link', 100 ); //Priority must be higher than 10