Replies
- Ravi on June 3, 2020 at 11:39 am in reply to: [Resolved] How To Show Posts From A Particular Taxonomy Only On User Profile #30407
Hello,
Thank you for posting. Please try the following code it will show posts from specific term_ids
/** * Modify query * * @param WP_Query $query Query object. */ function buddydev_filter_posts_by_cat( $query ) { // Return if not on user screen or current component is not buddyblog. if ( ! bp_is_user() || ! bp_is_current_component( 'buddyblog' ) ) { return; } if ( BUDDYBLOG_ARCHIVE_SLUG !== bp_current_action() ) { return; } $taxquery = array( array( 'taxonomy' => 'genre', // Replace this by user custom taxonomy. 'field' => 'id', 'terms' => array( 32 ), // Replace by your's term_ids to want to show 'operator'=> 'IN' ) ); $query->set( 'tax_query', $taxquery ); } add_action( 'pre_get_posts', 'buddydev_filter_posts_by_cat' );
Please let me know if it works or not.
Regards
Ravi - Ravi on June 1, 2020 at 5:55 pm in reply to: [Resolved] Can you help me with the small snippet #30374
Hello Kumar,
Please check the following code it will hide delete button if activity type is new blog post. Please modify as per your requirement.
/** * Check if the user can delete activity or not. * * @param bool $can_delete true|false * @param BP_Activity_Activity $activity Activity object. * * @return bool */ function buddydev_activity_user_can_delete( $can_delete, $activity ) { if ( isset( $activity->type ) && 'new_blog_post' == $activity->type ) { $can_delete = false; } return $can_delete; } add_filter( 'bp_activity_user_can_delete', 'buddydev_activity_user_can_delete', 10, 2 );
Regards
Ravi - Ravi on May 29, 2020 at 8:35 am in reply to: [Resolved] Disable Right and Left Panel on Community Builder #30312
Hello Eri,
You can disable left and right panel by navigating Customizer > Layout > Global. Please check the url set visibility to none to disable
Regards
Ravi - Ravi on May 28, 2020 at 9:21 pm in reply to: [Resolved] How to limit buddypress registrations #30310
Hello Tosin,
Thank you for the acknowledgement. I am glad that I could help.
Regards
Ravi - Ravi on May 28, 2020 at 9:10 pm in reply to: [Resolved] How to limit buddypress registrations #30308
Hello Tosin,
Please make sure page with mentioned id is in published state and site user count is greater than 5000 only then this code will work.
Regards
Ravi - Ravi on May 28, 2020 at 5:23 pm in reply to: [Resolved] How to limit buddypress registrations #30303
Hello Tosin,
Please try the following code. It will redirect new users to page with id ‘45565’
add_action( 'bp_template_redirect', function () { // If logged in nothing to do with it. if ( is_user_logged_in() || ! bp_is_register_page() ) { return; } $site_users = get_users( array( 'fields' => 'ID' ) ); $site_users_count = count( $site_users ); // If site user count is less than 5000 not need to redirect. if ( 5000 > $site_users_count ) { return; } // Check your conditions here. home_url to you page url. bp_core_redirect( get_page_link( 45565 ) ); } );
Please let me know if it works or not. One more question, Are you working with multisite then there will be a slight change?
Regards
Ravi - Ravi on May 28, 2020 at 11:25 am in reply to: [Resolved] How to limit buddypress registrations #30294
Hello Tosin,
Thank you for posting. Try the following code.
add_action( 'bp_template_redirect', function () { if ( bp_is_register_page() ) { // Check your conditions here. home_url to you page url. bp_core_redirect( home_url() ); } } );
Regards
Ravi Hello Carsten,
Yes, It sounds like a good fit to your needs.
Regards
Ravi- Ravi on May 27, 2020 at 6:25 pm in reply to: [Resolved] Can you help me with the small snippet #30274
Hello Kumar,
Thank you for posting. Are you looking a way to hide delete activity button for blog posts activities? If yes, please let me know which template pack you are using in BuddyPress so that I can help.
Regards
Ravi Hello Steven,
Thank you for posting. Just to hide the admin bar does need any specific plugin. You can hide it with the following code in your theme “functions.php”
add_filter( 'show_admin_bar', function () { return is_super_admin(); } );
It will only show admin bar to admin only.
Regards
Ravi