Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restrict Users from deleting notifications


  • hthornhillhww
    Participant

    @hthornhillhww

    Hi,

    I dont want to show my users the option to delete notifications from their profiles, i only want them to be able to mark them as read or unread, how can i remove the delete option?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

  • Venutius
    Moderator

    @venutius

    It looks like the function bp_the_notification_action_links() accepts $args that would allow you to remove the delete link. So you could overload your `members/single/notifications/notifications-loop.php file to include something like the following:

    $args = array(
        'links'  => array(
    	bp_get_the_notification_mark_link( $user_id )
    	)
    );

    and add this to the function call: bp_the_notification_links( $args )

    Something like that looks like it would work, not tested it though.


    hthornhillhww
    Participant

    @hthornhillhww

    Thanks for your response however i cant find the members/single.notification/notification-loop.php file in my them or plugins, not sure if i’m looking in completely the wrong place


    Venutius
    Moderator

    @venutius

    Ah ok,

    So first of all you need a child theme, there’s plenty on plugins available that wil set one up for you.

    Next you need to know which BP Template is being used by going to Settings>BuddyPress>Options, here you will see it’s either set to Legacy or Nouveau.

    Next create a directory in your childtheme called buddypress/members/single/notifications

    Next copy the file plugins/buddypress/bp-templates/(bp-nouveau or bp-legacy)/buddypress/members/single/notifications/notifications-loop.php to the notifications you created in your childtheme.

    You can then edit this file to add your changes. in here you will find the function call I mentioned for you to add the args to.


    hthornhillhww
    Participant

    @hthornhillhww

    brilliant, that is so helpful, thank you i will give it a go


    Venutius
    Moderator

    @venutius

    You are welcome.

    When you get to edit the file you will see something like this:

    <?php bp_the_notification_action_links(); ?>

    The extra code will need to go within a set of PHP tags just like the function call is.

    So your code should end up looking something like this:

    <?php $args = array(
        'links'  => array(
    	bp_get_the_notification_mark_link( $user_id )
    	)
    );?>

    place this in a new line before the modified function call:

    <?php bp_the_notification_action_links( $args ); ?>


    hthornhillhww
    Participant

    @hthornhillhww

    thanks for your help, I have got the page to only show the unread link but now when you hover over the link, it wont work as the format of the link is wrong, do you know why?

    This is the link before (top) and after (bottom)

    https://www.dropbox.com/s/zoiencz9qbweanr/links%20before%20and%20after%20change.jpg?dl=0

    and this is my code

    <?php $args = array(
    						'links'  => array(
    						bp_get_the_notification_mark_link( $user_id )
    						)
    						);?>
    						
    						<td class="notification-actions"><?php bp_the_notification_action_links( $args ); ?></td>

    Venutius
    Moderator

    @venutius

    Ah yes, slight correction required:

    <?php $args = array(
        'links'  => array(
    	bp_get_the_notification_mark_link( bp_displayed_user_id() )
    	)
    );?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar