BuddyDev

Search

[Resolved] Auto delete "already red" buddypress notification

  • Participant
    Level: Master
    Posts: 213
    smart life on #14955

    Hi,

    Can you please help me with sipped code to :
    Auto delete “already red” buddypress notification

    Most people lazy and don’t really take care of delete these, my web used shared hosting, i would like make this clear automatice right the time user read notification

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #14967

    Hi Julia,
    Please add the following code to your bp-custom.php

    
    
    /**
     * Delete Read notifications.
     */
    function buddydev_clear_read_notifications() {
        if( ! bp_is_my_profile() ) {
            return ;
        }
    
        BP_Notifications_Notification::delete( array(
    		'user_id'          => get_current_user_id(),
    		'is_new'           => 0,
    	) );
    
    }
    add_action( 'bp_notifications_screen_unread', 'buddydev_clear_read_notifications' );
    
    

    That will do it.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 213
    smart life on #14982

    Hi,

    1) It worked on case click on “read” button. It don’t work with click on view title link.

    2) Button:
    Read | Delete

    I found “|” classs is #text, but i tried to display:none
    ==> But it don’t work. How do i success delete “|”

    Thanks

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #14983

    Hello Julia,

    Please use the following code in your bp-custom.php.

    
    function buddydev_remove_separator( $retval, $r ) {
    	$retval = str_replace( ' | ', ' ', $retval );
    	return $retval;
    }
    add_filter( 'bp_get_the_notification_action_links', 'buddydev_remove_separator', 10, 2 );
    

    Thank You
    Ravi

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #14990

    Hi Julia,
    My code deletes all read notifications when you are on notifications page(unread). It does not do anything else.

  • Participant
    Level: Master
    Posts: 213
    smart life on #14994

    All coded worked as support.

    Can you please give a snipped code
    Make “Delete” button of “bunk action” in Notifications checked by defaul?

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #15052

    Sorry, That would need js and I will not recommend it doing here. I don’t think checking by default does any good too and the time spent on providing code is not justified.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved