Replies
- Tosin on June 13, 2023 at 12:54 pm in reply to: [Resolved] Buddyblog change activity excerpt length #49775
Thanks this is now resolved
Hello Ravi
Have you been able to test this
- Tosin on June 8, 2023 at 3:46 pm in reply to: [Resolved] Buddyblog change activity excerpt length #49709
I have tried this but did not work
// Adjust BuddyPress activity content excerpt length function adjust_bp_activity_excerpt_length($excerpt_length) { // Set your desired excerpt length here $new_excerpt_length = 200; // Change this value as per your requirement return $new_excerpt_length; } add_filter('bp_activity_excerpt_length', 'adjust_bp_activity_excerpt_length');
Hi Ravi
I cant still get it to work with HPOS enabled, kindly confirm if this is how your woocommerce advance settings (Custom data stores) is enabled in the image below.
Only the new WooCommerce orders tables should be enabled.
Thanks
- Tosin on May 30, 2023 at 6:00 am in reply to: [Resolved] Buddyblog pay per post improvement/suggestion #49620
Hello Brajesh,
How is the update progressing.
Thanks
Hey Brajesh
What’s your take on adding support for presto player for the new video upload field in buddyblog.
presto at https://prestoplayer.com/
Also would you still be considering adding the audio upload field.
Thanks
- Tosin on May 25, 2023 at 3:19 pm in reply to: Discussion on dealing with buddypress inactive users or dead profiles #49602
Thanks Brajesh now im clueless.
I hope other members can provide suggestions about this idea.
I have disabled HPOS but im still experiencing the expiry issue for sticky posts, I have sticky post expiry set to 7 days expiration but paid post are becoming unsticky within few minutes instead of 7 days
- Tosin on May 21, 2023 at 12:26 pm in reply to: Discussion on dealing with buddypress inactive users or dead profiles #49579
Thanks for the feddback Brajesh
Although I know nothing about CLI based solutions this is what I have now
function check_inactive_users_and_assign_role() { // Check if the current page is the BuddyPress sitewide activity directory page if ( function_exists( 'bp_is_activity_directory' ) && bp_is_activity_directory() ) { // Check if user is logged in if ( is_user_logged_in() ) { $users = get_users( array( 'fields' => 'ID', // Only retrieve the user IDs for efficiency 'role__not_in' => array( 'administrator' ), // Exclude users with the 'administrator' role 'number' => -1, // Retrieve all users at once ) ); foreach ( $users as $user_id ) { $last_activity = bp_get_user_last_activity( $user_id ); // Get the last activity timestamp if ( ! empty( $last_activity ) ) { $inactive_time = time() - strtotime( $last_activity ); // Calculate the time difference in seconds // Check if the user has been inactive for a year (31536000 seconds) if ( $inactive_time >= 31536000 ) { $ghost_member_role = 'ghost_member'; // The role slug for Ghost Member // Add the user to the Ghost Member role $user_obj = new WP_User( $user_id ); $user_obj->add_role( $ghost_member_role ); } } } } } } add_action( 'bp_loaded', 'check_inactive_users_and_assign_role' );
Maybe running this first code once a week might be better
/** * (Buddypress)- Remove users from the "Ghost Member" after login */ function remove_ghost_member_role_on_login( $user_login, $user ) { $ghost_member_role = get_role( 'ghost_member' ); // Get the Ghost Member role object if ( $ghost_member_role && in_array( $ghost_member_role->name, $user->roles ) ) { $user_obj = new WP_User( $user->ID ); $user_obj->remove_role( $ghost_member_role->name ); } } add_action( 'wp_login', 'remove_ghost_member_role_on_login', 10, 2 );
Since I dont have an efficient way for inactive user clean up without affecting site performance, maybe the method of cleanup should change, what would you suggest.
1. Automatic cleanup via code
2. Manual cleanup by clicking a button in admin area
3. Community cleanup by community members reporting other inactive users
4. Mix of both automatic cleanup and community clean up or the 3Personally I would have preferred automatic approach to save time
what’s your opinion
thanks
- Tosin on May 18, 2023 at 12:22 pm in reply to: Discussion on dealing with buddypress inactive users or dead profiles #49560
Now how will the code affect site performance if the site has a least one million registered members. If the site has a large number of registered members, iterating through all users using get_users() and checking their activity status can potentially impact site performance, especially if the operation is performed on every page load.
Will this code be better
function schedule_inactive_users_check() { if ( ! wp_next_scheduled( 'check_inactive_users_event' ) ) { wp_schedule_event( time(), 'daily', 'check_inactive_users_event' ); } } add_action( 'bp_loaded', 'schedule_inactive_users_check' ); function check_inactive_users_and_assign_role() { $users = get_users( array( 'number' => 100 ) ); // Get 100 users at a time foreach ( $users as $user ) { $last_activity = bp_get_user_last_activity( $user->ID ); // Get the last activity timestamp if ( ! empty( $last_activity ) ) { $inactive_time = time() - strtotime( $last_activity ); // Calculate the time difference in seconds // Check if the user has been inactive for a year (31536000 seconds) if ( $inactive_time >= 31536000 ) { $ghost_member_role = 'ghost_member'; // The role slug for Ghost Member // Add the user to the Ghost Member role $user_obj = new WP_User( $user->ID ); $user_obj->add_role( $ghost_member_role ); } } } } function run_inactive_users_check() { check_inactive_users_and_assign_role(); // Check if there are more users to process if ( count( get_users() ) > 0 ) { wp_schedule_single_event( time() + 10, 'run_inactive_users_check' ); // Schedule the next batch after 10 seconds } } add_action( 'check_inactive_users_event', 'run_inactive_users_check' );