Skip to:
Content
Pages
Categories
Search
Top
Bottom

Moderator can only trash his own posts


  • enkoes
    Participant

    @enkoes

    Hi, good day!

    How can we come up with a code so that moderators can only trash his OWN topic/reply but not those posted by others? i.e. to hide admin link “bin” for topic/reply posted by others but display “bin” for his own (as moderator) post.

    Regards.

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

  • enkoes
    Participant

    @enkoes

    Today tried testing this very ‘rough’ piece of code, failed hopelessly with my very limited knowledge of coding:

    add_filter('bbp_topic_admin_links', 'rew_no_trash_except_own', 10, 2);
    add_filter('bbp_reply_admin_links', 'rew_no_trash_except_own', 10, 2);
    
    function rew_no_trash_except_own ($links, $topic_id) {
        if (!bbp_is_user_keymaster() && !bbp_is_topic_author(get_current_user_id(), $topic_id)) {
            unset($links['trash']);
        }
        return $links;
    }

    I think the direction is somewhat correct. Hope to get expert guide on this issue.

    Regards.


    Robin W
    Moderator

    @robin-w

    you’re close !!

    Untested, but try

    add_filter('bbp_topic_admin_links', 'rew_no_trash_topic_except_own', 10, 2);
    add_filter('bbp_reply_admin_links', 'rew_no_trash_reply_except_own', 10, 2);
    
    function rew_no_trash_topic_except_own ($links, $topic_id) {
        if (!bbp_is_user_keymaster() && get_current_user_id() != bbp_get_topic_author_id( $topic_id )) {
    			unset($links['trash']);
    		} 
    	
        return $links;
    }
    
    function rew_no_trash_reply_except_own ($links, $reply_id) {
        if (!bbp_is_user_keymaster() && get_current_user_id() != bbp_get_reply_author_id( $reply_id )) {
    			unset($links['trash']);
    		} 
    	
        return $links;
    }

    enkoes
    Participant

    @enkoes

    Legend! It works exactly like what I want.

    Thanks a lot!


    Robin W
    Moderator

    @robin-w

    glad to have helped !

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar