Skip to:
Content
Pages
Categories
Search
Top
Bottom

Delete Topic Function


  • gjwarez
    Participant

    @gjwarez

    Hi there,

    I have this problem that users only can edit there own topics and not delete them.
    If i upgrade their accounts with “moderate” they can also delete other users topics.

    Now the strange thing is that when i edit the roles (with WPFront User Role Editor)
    the option delete_topic has no effect, but with delete_others_topic it suddenly can!
    But then again they can delete all topics.

    Is there a solution that i missed?

    Thank u

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

  • Robin W
    Moderator

    @robin-w

    there are two capabilities within bbpress roles

    ‘delete_topics’
    ‘delete_others_topics’

    Looks like the plugin is changing the wrong one.

    I presume it is the participant role that you like delete topic on ?

    If so, please come back and confirm, and I’ll cut a quick filter for you after the weekend if you know how to add some code to your functions file.


    gjwarez
    Participant

    @gjwarez

    Hey Robin,

    Thanks for your reply,
    I tried some other things but it’s still not working,

    First i disabled the role plugin and then i add the “delete_topic true line”
    to the participant role in capabilities.php but nothing happened.
    But When i add the “delete_others_topics true line” there it will work fine
    (but again for all users and topics)

    So the plugin and the by hand modification are the same in this case.

    U have any idea?

    Thanks


    Robin W
    Moderator

    @robin-w

    What line did you alter in which capabilities php file?
    and what did you alter it to?


    gjwarez
    Participant

    @gjwarez

    Hey Robin,

    I add the line in this php file location
    wp-content/plugins/bbpress/includes/core/capabilities.php

    
    		// Participant/Default
    		case bbp_get_participant_role() :
    		default :
    			$caps = array(
    
    				// Primary caps
    				'spectate'              => true,
    				'participate'           => true,
    
    				// Forum caps
    				'read_private_forums'   => true,
    
    				// Topic caps
    				'publish_topics'        => true,
    				'delete_topics'         => true,
    				'edit_topics'           => true, 
    				
    				// Reply caps
    				'publish_replies'       => true,
    				'edit_replies'          => true,
    				
    				// Topic tag caps
    				'assign_topic_tags'     => true,
    			);
    
    			break;
    	}
    
    

    In this case the delete_topic does not work,
    if i put delete_others_topics there it will work for all users.


    Robin W
    Moderator

    @robin-w

    ok, I’m running training all this weekend, will come back to you early next week !


    Robin W
    Moderator

    @robin-w

    ok, interesting, whilst altering that file on a permanent basis is not a good idea, it should have worked.

    I’m not familiar with the role editor, does it let you change the default participant role, or did you create a new one with the delete topic capability?

    I’d eliminate plugin and theme issues by

    Check other plugins

    Check that no other plugins are affecting this.

    Turn off all other plugins apart from bbpress, and see if that fixes the problem. If the problem is resolved, add back one at a time to see which is causing the conflict.

    Check themes

    If plugins are not the cause, then it may be a theme issue. Switch to a default theme, such as twentytwelve, and test.

    Let us know how you get on


    gjwarez
    Participant

    @gjwarez

    Hey Robin,

    The Role Editor let you change all the roles but can also create new roles.
    I tried both options to upgrade participant with delete_topic an i tried to make a new role with delete_topic and assign it to the members.
    Besides this i deactivated the plugin and i put the delete_topic manually (like previous post)
    all of this did not work.

    I also noticed that the other delete functions like delete_reply are also not working.
    but again when i add delete_others_reply it will work fine for all users replies.

    I will try turning of the plugins and themes but i don’t think that is the answer.

    Thank u and ill let u know.


    Robin W
    Moderator

    @robin-w

    ‘I will try turning of the plugins and themes but i don’t think that is the answer.’

    may well not be, but lets eliminate !


    gusrb84
    Participant

    @gusrb84

    I have same issue! delete_others_replies work, but not delete_replies..

    Temporary solution would be changing bbpress core (/includes/replies/capabilities.php)
    from:

    case 'delete_reply' :
    // Get the post
    $_post = get_post( $args[0] );
    if ( !empty( $_post ) ) {
    	// Get caps for post type object
    	$post_type = get_post_type_object( $_post->post_type );
    	$caps      = array();
    	// Add 'do_not_allow' cap if user is spam or deleted
    	if ( bbp_is_user_inactive( $user_id ) ) {
    	$caps[] = 'do_not_allow';
    	// Moderators can always edit forum content
    	} elseif ( user_can( $user_id, 'moderate' ) ) {
    	$caps[] = 'moderate';
    	// Unknown so map to delete_others_posts
    	} else {
    	$caps[] = $post_type->cap->delete_others_posts;
    	}
    }
    break;

    To:

    case 'delete_reply' :
    // Get the post
    $_post = get_post( $args[0] );
    if ( !empty( $_post ) ) {
    	// Get caps for post type object
    	$post_type = get_post_type_object( $_post->post_type );
    	$caps      = array();
    	// Add 'do_not_allow' cap if user is spam or deleted
    	if ( bbp_is_user_inactive( $user_id ) ) {
    	$caps[] = 'do_not_allow';
    	// Moderators can always edit forum content
    	} elseif ( user_can( $user_id, 'moderate' ) ) {
    	$caps[] = 'moderate';
    	// User is author so allow edit if not in admin
    	} elseif ( !is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {
    	$caps[] = $post_type->cap->delete_posts;
    	// Unknown so map to delete_others_posts
    	} else {
    	$caps[] = $post_type->cap->delete_others_posts;
    	}
    }
    break;

    But I do not want to touch the core. How can I update my functions.php file to do the same? (i.e. add_filter)

    I’m very new to WP and BBP..

    This sounds like we need to fix bbPress core, feel free to create a ticket on Trac and we can take a closer look https://bbpress.trac.wordpress.org

    Edit: https://bbpress.trac.wordpress.org/ticket/2685

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