BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 903

    Hello Brajesh,

    How is the update progressing.

    Thanks

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: BuddyBlog Pro upload video field #49605

    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

  • Participant
    Level: Guru
    Posts: 903

    Thanks Brajesh now im clueless.

    I hope other members can provide suggestions about this idea.

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: Buddyblog pay per post expiration issue #49580

    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

  • Participant
    Level: Guru
    Posts: 903

    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 3

    Personally I would have preferred automatic approach to save time

    what’s your opinion

    thanks

  • Participant
    Level: Guru
    Posts: 903

    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' );
     
  • Participant
    Level: Guru
    Posts: 903

    This is example code for classifying user inactive for a year

     function check_inactive_users_and_assign_role() {
        $users = get_users(); // Get all users
    
        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 );
                }
            }
        }
    }
    add_action( 'bp_loaded', 'check_inactive_users_and_assign_role' );
     
  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: BuddyBlog Pro upload video field #49499

    Hi Brajesh,

    I really like this idea, I was wondering if you can also include a field for uploading Audio files

    Thanks

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Branded login script #49477

    This is now resolved there was another popup login form in the same page with similar form ID

  • Participant
    Level: Guru
    Posts: 903

    Thanks for the feedback Brajesh

    You got the suggestion right

    I want a settings in the product section to also enable users to mark old posts or unpaid posts and expired paid posts as sticky.

    So when user edits an old post they can select a product price and promote/feature old unpaid post as sticky

    NEW WORKFLOW ON POST EDIT
    Clicking the (update) button will now redirect the user to cart or checkout page, after successful payment the post will now be updated and also become sticky

    NOTE – this new workflow will only take effect if a price option was selected in the pay per post field while updating an old post.

    Thanks

    Thanks