Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 3,826 through 3,850 (of 32,517 total)
  • Author
    Search Results
  • #199037

    In reply to: Comments Blacklist

    Robin W
    Moderator

    ok, try this plugin

    bbp blacklist checker

    once activated go to tools>bbp blacklist checker

    This lets you switch off the code that is causing the issue.

    It’s just a bit of testing code, not intended for permanent live use, but may help confirm if it’s bbpress or something behind that is causing the issue.

    Try it for both anew post and an edited one

    #199003

    In reply to: Layout for Categories

    pixelzen
    Participant

    Yes I got that far, not sure how to use modify the following code just for that sepecific category/forum This is the code for the discussion page

    <?php
    /**
    * [g1_bbp_forums] shortcode callback function.
    *
    * @param array $atts
    * @param string $content
    * @return string
    */
    function g1_bbp_forums_shortcode( $atts, $content ) {
    /* We need a static counter to trace a shortcode without the id attribute */
    static $counter = 0;
    $counter++;
    extract( shortcode_atts( array(
    ‘id’ => ”,
    ‘class’ => ”
    ), $atts, ‘g1_bbp_forums’ ) );
    // Compose final HTML id attribute
    $final_id = strlen( $id ) ? $id : ‘g1-bbp-forums-‘ . $counter;
    // Compose final HTML class attribute
    $final_class = array(
    ‘g1-bbp-forums’,
    );
    $final_class = array_merge( $final_class, explode( ‘ ‘, $class ) );
    // Note: private and hidden forums will be excluded via the
    // bbp_pre_get_posts_normalize_forum_visibility action and function.
    $query = new WP_Query( array(
    ‘post_type’ => bbp_get_forum_post_type(),
    ‘post_parent’ => $settings[‘parent_forum’],
    ‘post_status’ => bbp_get_public_status_id(),
    ‘posts_per_page’ => get_option( ‘_bbp_forums_per_page’, 50 ),
    ‘ignore_sticky_posts’ => true,
    ‘no_found_rows’ => true,
    ‘orderby’ => ‘menu_order title’,
    ‘order’ => ‘ASC’
    ) );
    if ( ! $query->have_posts() ) {
    return ”;
    }
    // Start output buffer
    ob_start();
    ?>
    <div class=”<?php echo implode( ‘ ‘, array_map( ‘sanitize_html_class’, $final_class ) ); ?>”>
    <div class=”g1-collection g1-collection–grid g1-collection–one-third g1-collection–simple”>

      <?php while ( $query->have_posts() ) : $query->the_post(); ?>
      <li class=”g1-collection__item”>
      <article>
      <?php if ( has_post_thumbnail() ): ?>
      <figure class=”entry-featured-media”>

      post->ID ); ?>”>
      <?php the_post_thumbnail( ‘g1_one_third’ ); ?>

      </figure>
      <?php else: ?>
      <?php echo do_shortcode( ‘[placeholder icon=”camera” size=”g1_one_third”]’ ); ?>
      <?php endif; ?>
      <div class=”g1-nonmedia”>
      <div class=”g1-inner”>
      <header class=”entry-header”>
      <h3 class=”entry-title”>
      post->ID ); ?>”><?php bbp_forum_title( $query->post->ID ); ?>
      </h3>
      <p class=”entry-meta g1-meta”>
      <span><?php _e( ‘Topics’, ‘bbpress’ ); ?>: <?php bbp_forum_topic_count( $query->post->ID ); ?></span>
      <span><?php bbp_show_lead_topic() ? _e( ‘Replies’, ‘bbpress’ ) : _e( ‘Posts’, ‘bbpress’ ); ?>: <?php bbp_show_lead_topic() ? bbp_forum_reply_count( $query->post->ID ) : bbp_forum_post_count( $query->post->ID ); ?></span>
      </p>
      </header>
      <div class=”entry-summary”>
      <?php the_excerpt(); ?>
      </div>
      </div>
      </div>
      </article>

      <?php endwhile; ?>

    </div>
    </div>
    <?php
    // Reset the $post global
    wp_reset_postdata();
    // Return and flush the output buffer
    return ob_get_clean();
    }
    add_shortcode( ‘g1_bbp_forums’, ‘g1_bbp_forums_shortcode’ );

    #198995
    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

    #198994
    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

    #198981
    Antipole
    Participant

    Yes AsynCRONousbbPress Subscriptions works out of-the-tin as described. But it turns a single email with 123 Bcc addressees into 123 single addressee emails, which breaks my ISP’s limit of 100 emails/hour. Sigh!

    I have finally achieved my own plugin which hooks onto wp_mail() and which chops up outgoing emails into multiple emails with a configured maximum Bcc addressee limit. So with my ISP’s limit of 10 addressees, my 123 notifications get sent in 12 emails each with 10 addressees plus 1 with the last 3.

    It works with all outgoing emails that supply the Bcc addresses in an array (as does bbPress) or a flat list (as does Subscribe2 for WP post notifications).

    Code here.

    #198970
    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.

    aidan1387
    Participant

    I’m trying to import IPB database to bbPress with “Tools>Forums>Import Forums”.
    But I always get a log that nothing is converted:

    
    Conversion Complete
    
    No reply_to parents to convert
    
    No replies to convert
    
    No tags to convert
    
    No super stickies to stick
    
    No stickies to stick
    
    No topics to convert
    
    No forum parents to convert
    
    No forums to convert
    
    No passwords to clear
    
    No users to convert
    
    Starting Conversion
    

    Select Platform == Invision.
    IP.Board version is v3.4.6.
    How I could troubleshoot this? Where should I start at least?.

    #198935
    byzane
    Participant

    Sorry I misspoke. I was unable to run the code through my functions.php file, but it seems to be functioning through a snippet plugin:

    Code Snippets

    My bad.

    #198933
    byzane
    Participant

    I’ve been doing a lot of research and I am wondering the same thing. The closest I have found was this:

    Allow Participants to Trash / own Topics and Posts

    However, that was posted 2 years ago and it seems the code doesn’t work anymore. Ironically, @robin-w it’s your modification xD. Would you mine dropping some insight as to why the code isn’t functioning properly anymore, please. 🙁

    #198932
    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

    #198924
    ryolu22
    Participant

    Hay. New here. I tried to create a theme from scracth using pure html php and etc

    At first, it was normal. It functions normally and the UI is not as messed up as right now.

    And now out of anything, it suddenly messed up. Checkout my website here if you wanna see it https://psikologipolda.com/konsul-online/

    I tried uninstalling bbpress, tried using different way of calling the forums and it still doesn’t work. Try looking at the css and tweak it, still doesn’t change.

    Any idea? or any place I should edit my code?

    FYI the page only used:
    the content.php (that is used as a template for any content including the forum)
    and the custom template for that page only.php

    #198850

    In reply to: Newby Question

    Robin W
    Moderator

    put this in your theme’s custom css area

    .bbp-author-ip {
    display : none !important ;
    }
    #198817
    amnion
    Participant

    It seems to be an issue finding all the replies. In the database all those posts have the type “reply” as post_type. I don’t get it. The link matches the format for forums and topics, which are able to find all the posts just fine.

    …/wp-admin/edit.php?post_type=reply

    In addition to this, all the reply post authors are being input as 0, which makes them anonymous. I have that unchecked in the settings.

    Is there a way to permanently delete bbpress and all its contents so I can reinstall fresh? EDIT: I found the answer to this question. https://codex.bbpress.org/getting-started/installing-bbpress/deleting-bbpress/

    #198804
    Robin W
    Moderator

    bbp_has_forumms is just a forum version of wordpress has_posts.

    The code you first posted – where is it, in your functions, in a plugin or where?

    Robin W
    Moderator

    ok, given that I probably amswered your original Q too literally let’s re-phrase that –

    bbpress requires you to have an account on your website that is hooked to the wordpress software running on your website – which is what my original answer was. The username, password and all other details are only held only on your website. Nothing is passed to any other site (unless you add code to do so).

    You are not required to have a wordpress.org username to use bbpress

    #198793
    w3215
    Participant

    Sorry–I think there was a typo earlier. The shortcodes are here:https://codex.bbpress.org/features/shortcodes/

    Shortcode for create new topic page: [bbp-topic-form]
    for new topic specific to an id: [bbp-topic-form forum_id=$forum_id]

    #198792
    w3215
    Participant

    Hi There. I am new to bbpress, but I had a similar requirement, and I believe the following works:

    1) Create a page where users can create a new topic. To do this, you can use one of these shortcodes: for new topic page: [bbp-topic-form]
    for topic specific to forum id: [bbp-topic-form]

    2) Put a link to this page in the menu. (so in your menu, have a “Create a New Topic” link that takes you to the new topic page).

    #198760
    Pleiades
    Participant

    Thanks, Robin W.
    It’s a site I inherited with 100+ plugins. I’m trying to unravel the necessary from the superfluous but too many things keep breaking.

    I’m trying to put traps in the code to see where conflicts are occurring. It seems like bbp_has_forums calls methods that call methods that call methods…

    I would appreciate if someone could help shortcircuit this process and point me to the place where the actual test is happening.

    Please forgive my snarky comment earlier. This site has been a cluster and I’ve been frustrated by a long list of plugins with no doc and no response to developers.

    Robin W
    Moderator

    totally untested but try

    function rew_status_transitions( $post ) {
    	if ( $post->post_type == 'reply') {
    		$topic = bbp_get_reply_topic_id ($post->ID) ;
    		//update the post meta
    		update_post_meta ($topic, '_bbp_last_active_time' , $post->post_date) ;
    	}
    	 
    }
    add_action(  'future_to_publish',  'rew_status_transitions', 10, 1 );
    #198757
    Robin W
    Moderator

    it’s not much of a codex, but it’s the only one there is! I wrote quite a lot if it when I started using bbpress – I’m just a bbpress user who helps on here. If you’d like to contribute, post suggested improvements and I’ll add them – just saying 🙂

    So if your code was working a few days ago, and it now isn’t, then you must have upgraded the theme, a plugin or changed something else. Without knowing what it’s hard to help.

    neon67
    Participant

    It’s working! Great!
    1.New scheduled topic: time of publication and the timestamp in tracker coincide now!
    2.Old topic (written 5 years ago) after time-correction for today – appear in the tracker correctly!
    3.But, does not work for scheduled replay in topic. If replace the word “topic” for word “replay” in the code – will this work?

    #198735
    Pleiades
    Participant

    I have a bbPress forum integrated with WooCommerce.
    Until a few days ago it was working fine, but now

    $uid = bbp_get_current_user_id();
    
    if ( bbp_has_forums( array(
         'author' => $uid
     )) ) :

    returns bool(false) regardless of the user or user role.

    On a side note, when searching codex.bbpress.org, the results I (don’t) get:

    bbp_get_current_user_id – “Sorry, no posts matched your criteria.”
    bbp_has_forums – “Sorry, no posts matched your criteria.”
    bbp_forums – “Sorry, no posts matched your criteria.”
    bbp_the_forum – “Sorry, no posts matched your criteria.”

    I understand these are just wrappers for WP_Query, but there are some obviously also forum-specific options. It doesn’t seem like much of a codex. Just saying.

    Robin W
    Moderator

    this is more complicated than it as first looks, as there is forum data that needs updating

    but as a start

    function rew_status_transitions( $post ) {
    	if ( $post->post_type == 'topic') {
    		//update the post meta
    		update_post_meta ($post->ID, '_bbp_last_active_time' , $post->post_date) ;
    	}
    	 
    }
    add_action(  'future_to_publish',  'rew_status_transitions', 10, 1 );
    #198659

    In reply to: Links in new topic

    Oaz
    Participant

    yes, apostrophes are okay now, with same result as before : links do not appear anymore in new topics. i disable the code, links display…

    So strange this function is not in bbpresscore, I suppose many of us need it..

    Anyway, thank you so much for your help and patience Robin. I spent much time on this without results. I think I’ll just lokk for another system than bbpress for my forum..

Viewing 25 results - 3,826 through 3,850 (of 32,517 total)
Skip to toolbar