Robin W (@robin-w)

Forum Replies Created

Viewing 25 replies - 7,151 through 7,175 (of 14,232 total)
  • @robin-w

    Moderator

    for anyone finding this topic

    I kicked this code around to improve it and also stop the 404 error when a participant trashes a topic, so latest version is

    /*Customize the BBPress roles to allow Participants to trash topics*/
    add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 );
    
    function ST_add_role_caps_filter( $caps, $role ){
        // Only filter for roles we are interested in!
        if( $role == bbp_get_participant_role() ) {
    			//only change delete topics 
    			$caps ['delete_topics']= true ;
    	}
    	return $caps;
    }
    /*then only allow participants to trash their own topics*/
    add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 );
    
    function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){
    	// apply only to delete_topic
    	if ( $cap == "delete_topic" ){
    		// 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 );
    			
    			// 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 ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) {
                    $caps      = array();
    				
    			// Unknown so do not allow
    			} else {
    				$caps[] = 'do_not_allow';
    			}
    		}
    	}	
    	// return the capabilities
    	return $caps;
    	}
    
    //then redirect to the forum after trashing topic
    add_action('bbp_template_redirect', 'ST_trash_topic_check', 8);
    
    //check if topic has been trashed by author and show forum if it has
    function ST_trash_topic_check() {
    	$topic_slug = get_option( '_bbp_topic_slug') ;
    	//quick check if we need to do this function, so bail if not a topic
    	if (strpos($_SERVER['REQUEST_URI'], $topic_slug) == FALSE) return ;
    	$forum_slug = bbp_get_root_slug() ;
    	//if check is set (ie we prefix forums with the forum slug) then part 1 will be forum slug and part 2 will be topic slug, if not part 1 will be topic slug
    	$check = bbp_include_root_slug() ;
    	$link = explode('/',$_SERVER['REQUEST_URI']);
    	//next we need the topic id (post id) of the topic so we need to check if it is a topic and if so, find the topic id
    	if (is_user_logged_in() && $check && $link[1] == $forum_slug && $link[2] == $topic_slug ) {
    		$post = bsp_get_page_by_slug( $link[3], OBJECT, 'topic' );
    		$login_check=1 ;
    		} 
    	elseif (is_user_logged_in() && empty($check) && $link[1] === $topic_slug) {
    		$post = bsp_get_page_by_slug( $link[2], OBJECT, 'topic' );
    		$login_check=1 ;
    	}
    	//now we need to check if the topic has been trashed by author
    	if (!empty ($login_check) && $post->post_status == 'trash' && $post->post_author == get_current_user_id() ) {
    		$topic_id =  $post->ID;
    		//then redirect to the forum we came from
    		$forum = bbp_get_forum_permalink (bbp_get_topic_forum_id (  $topic_id )) ;
    		wp_redirect ($forum) ;
    		exit ;
    	}
    	else return ;
    					
    }

    I’ll add this function into my style pack plugin shortly

    bbp style pack

    @robin-w

    Moderator

    I kicked this code around to improve it and also stop the 404 error when a participant trashes a topic, so latest version is

    /*Customize the BBPress roles to allow Participants to trash topics*/
    add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 );
    
    function ST_add_role_caps_filter( $caps, $role ){
        // Only filter for roles we are interested in!
        if( $role == bbp_get_participant_role() ) {
    			//only change delete topics 
    			$caps ['delete_topics']= true ;
    	}
    	return $caps;
    }
    /*then only allow participants to trash their own topics*/
    add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 );
    
    function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){
    	// apply only to delete_topic
    	if ( $cap == "delete_topic" ){
    		// 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 );
    			
    			// 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 ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) {
                    $caps      = array();
    				
    			// Unknown so do not allow
    			} else {
    				$caps[] = 'do_not_allow';
    			}
    		}
    	}	
    	// return the capabilities
    	return $caps;
    	}
    
    //then redirect to the forum after trashing topic
    add_action('bbp_template_redirect', 'ST_trash_topic_check', 8);
    
    //check if topic has been trashed by author and show forum if it has
    function ST_trash_topic_check() {
    	$topic_slug = get_option( '_bbp_topic_slug') ;
    	//quick check if we need to do this function, so bail if not a topic
    	if (strpos($_SERVER['REQUEST_URI'], $topic_slug) == FALSE) return ;
    	$forum_slug = bbp_get_root_slug() ;
    	//if check is set (ie we prefix forums with the forum slug) then part 1 will be forum slug and part 2 will be topic slug, if not part 1 will be topic slug
    	$check = bbp_include_root_slug() ;
    	$link = explode('/',$_SERVER['REQUEST_URI']);
    	//next we need the topic id (post id) of the topic so we need to check if it is a topic and if so, find the topic id
    	if (is_user_logged_in() && $check && $link[1] == $forum_slug && $link[2] == $topic_slug ) {
    		$post = bsp_get_page_by_slug( $link[3], OBJECT, 'topic' );
    		$login_check=1 ;
    		} 
    	elseif (is_user_logged_in() && empty($check) && $link[1] === $topic_slug) {
    		$post = bsp_get_page_by_slug( $link[2], OBJECT, 'topic' );
    		$login_check=1 ;
    	}
    	//now we need to check if the topic has been trashed by author
    	if (!empty ($login_check) && $post->post_status == 'trash' && $post->post_author == get_current_user_id() ) {
    		$topic_id =  $post->ID;
    		//then redirect to the forum we came from
    		$forum = bbp_get_forum_permalink (bbp_get_topic_forum_id (  $topic_id )) ;
    		wp_redirect ($forum) ;
    		exit ;
    	}
    	else return ;
    					
    }

    I’ll add this function into my style pack plugin shortly

    bbp style pack

    @robin-w

    Moderator

    this site only does this for the wordpress and bbpress sites.

    I’ll take a look at the plugin above soon, but tied up with other stuff at the moment

    In reply to: Comments Blacklist

    @robin-w

    Moderator

    Not sure why it does not for an edited post.

    In reply to: Comments Blacklist

    @robin-w

    Moderator

    ok, can you check if this happens with that word in a NEW post.

    I just want to understand if having blacklisted a post, it is having trouble reassessing it, or the issue is more core

    In reply to: Comments Blacklist

    @robin-w

    Moderator

    hmm…

    can you post the exact error message you are getting

    @robin-w

    Moderator

    glad you are fixed, but you have a tough ISP !!

    In reply to: Comments Blacklist

    @robin-w

    Moderator

    are you page caching ?

    @robin-w

    Moderator

    not an easy option.

    yes favorites are stored against a user.

    This gives the difficulty that you either:

    a) count favorites on then fly – ie on every page load you would cycle through each user and log the topics they have favorited and count them into an array – this will slow the site and it has to happen on every page load. you’d then store these into post meta.
    b) create some code that will count these using cron every so often, and update post meta
    c) link to the favorite button. So it would need to add when favorited and deduct when unfavorited. then you would need to allow for topics being trashed etc.

    a) is the easiest, but still a chunk of code and has site implications
    b) is probably the most practical, but will only be as current as you run cron, so could be say an hour out of date
    c) is a real bunch of code I suspect, but would be the best solution on a big website.

    @robin-w

    Moderator

    glad it’s working – I’ll take a look later 🙂

    @robin-w

    Moderator

    put this in your child theme’s functions file

    function rew_breadcrumbs ($args) {
    	
    	$args['home_text'] = 'your new words here';
    	return $args ;
    	
    }
    
    add_filter('bbp_before_get_breadcrumb_parse_args', 'rew_breadcrumbs');

    or use

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>Breadcrumbs

    In reply to: Forum Messed up…

    @robin-w

    Moderator

    hmm…looks like the forums are displaying within a ccss element called title-box

    Otherwise not sure I can help.

    It is theme/css related

    @robin-w

    Moderator

    @robin-w

    Moderator

    great – glad you are fixed

    @robin-w

    Moderator

    insults – yeh that’ll work 🙂

    @robin-w

    Moderator

    that’s what spectator should do.

    Suggest you set up a test user and check that that works.

    @robin-w

    Moderator

    ok, I think your site has issues.

    In reply to: Breadcrumb

    @robin-w

    Moderator

    it would be good to post the solution to help others seeing this thread later 🙂

    In reply to: Newby Question

    @robin-w

    Moderator

    put this in your theme’s custom css area

    .bbp-author-ip {
    display : none !important ;
    }

    @robin-w

    Moderator

    that measures site loading, not server performance as such, eg it doesn’t test dadatabase writes.

    cache will not affect non cache actions such as post submission

    I’d suggest you talk to your host providers.

    In reply to: Newby Question

    @robin-w

    Moderator

    ip address only shows for keymasters

    @robin-w

    Moderator

    empty the setting and the check should not happen

    @robin-w

    Moderator

    not really bbpress related – This is server/theme/other plugins issue.

    My test site which is full of stuff takes 1-2 seconds for a post, it is on a shared server, so depends on what else is happening on that server with other websites.

    I would ask that why your forum is so dependant on the need for lightening speed of posting, is the content really that boring ? Few users worry about posting speed, as longs as the site displays posted stuff in good speed:-)

    In reply to:

    @robin-w

    Moderator

    not really bbpress related – This is server/theme/other plugins issue.

    My test site which is full of stuff takes 1-2 seconds for a post, it is on a shared server, so depends on what else is happening on that server with other websites.

    I would ask that why your forum is so dependant on the need for lightening speed of posting, is the content really that boring ? Few users worry about posting speed, as longs as the site displays posted stuff in good speed:-)

    In reply to: Newby Question

    @robin-w

    Moderator

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>Topic/Rely Display item 13

Viewing 25 replies - 7,151 through 7,175 (of 14,232 total)