Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 8,876 through 8,900 (of 32,505 total)
  • Author
    Search Results
  • #161602

    In reply to: Slow to Post

    daniellajos.nl
    Participant

    For our site, with 121 forums, +150k topics and +1.1m replies, it could take up 30s before something is posted. I traced it down to this query:

    
            //$voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
    

    includes/topics/functions.php, line 2610. It uses an OR clause, and MySQL (only in 5.1.73?) isn’t able to use an index anymore after a certain amount of records in the wp_posts table. I replaced the query with an UNION statement, and it executes much faster now, since it is using indexes again (as the EXPLAIN statements show me on a database with and without this amount of replies/topics):

    
            $unionQuery = "SELECT COUNT( DISTINCT post_author )
                FROM (
                    SELECT post_author
                    FROM {$wpdb->posts}
                    WHERE post_parent = %d AND post_status = '%s' AND post_type = '%s'
                  UNION
                    SELECT post_author
                    FROM {$wpdb->posts}
                    WHERE ID = %d AND post_type = '%s'
                  ) AS alias;";
        $voices = $wpdb->get_col( $wpdb->prepare( $unionQuery, $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
    
    #161601
    Estellka
    Participant

    Hello there!
    I would like to understand the difference between

    [bbp-search] – Display the search input form.
    [bbp-search-form] – Display the search form template.

    I tried both of the shortcodes and they gave the same result, and my english is not good enough for me to understand the difference by reading the description. So please help.

    and I have the same question for

    [bbp-reply-form] – Display the ‘New Reply’ form.
    [bbp-single-reply id=$reply_id] – Display a single reply eg. [bbp-single-reply id=32768]

    and for

    [bbp-topic-form] – Display the ‘New Topic’ form where you can choose from a drop down menu the forum that this topic is to be associated with.
    [bbp-topic-form forum_id=$forum_id] – Display the ‘New Topic Form’ for a specific forum ID.
    [bbp-single-topic id=$topic_id] – Display a single topic. eg. [bbp-single-topic id=4096]

    and for

    [bbp-forum-form] – Display the ‘New Forum’ form.
    [bbp-single-forum id=$forum_id] – Display a single forums topics. eg. [bbp-single-forum id=32]

    thank you for your answers!

    #161597
    Estellka
    Participant

    Hello everyone,
    first, I would like to apologize if my writting is not very good, but I’m french and I’m not used in english phrases. And that’s why I dont’ understand some explainations on the blog. so please be soft with me.

    I would like to create a page wich gives a view of the last replies of my forum. I tried to create a new page with the short code [bbp-single-view id="last-replies"] but it does’n work when I clik on that page I have a notice “Aucun sujet n’a été trouvé ici!” which means “no topic has been found here!”

    I have others questions about short-codes meaning, but I’m going to ask it in another topics.

    thanks for your answers.

    here my forum: http://revonssavons.fr/WordPress/forums/Forum/accueil/

    Robert.S
    Participant

    Thanks a bunch for the code, both @robkk and @undergroundnetwork!

    I’m running Avada theme, with latest WordPress 4.2.1 and BBPress 2.5.7 and this works perfectly.

    Seems like this *should* be an option in WordPress when BBPress is installed: “Check the box to include Forum Topics and Replies in the sitewide search”. Would be a helpful addition.

    Luckily we have this resource, so thanks again for the code snippets.

    #161572
    Henrijs Kons
    Participant

    Ok yet again found solution on my own.

    Existing script was almost valid, problem was that author had hard coded table prefixes which I changed to use prefixes from WP configuration, now it works like I wanted.

    And here I posted my edited script for other user use http://pastebin.com/ANBwipYR

    #161570
    Piroglu
    Participant

    Hello,
    I want to show the most recent reply on my home page but when I try to make it with the widget I can only see the related topic name, not reply.

    I am using Enfold theme and I repaired the forum one by one but couldn’t success.
    I checked all forum pages, any help will be very much appreciated.

    http://myboxtr.com

    I am getting;

    Piroglu on I don t want to see the topic name here
    30 minutes ago

    I want to see;

    Piroglu on This is my reply for this topic
    30 minutes ago
    #161558
    23creative
    Participant

    Also in form-reply.php & form-topic.php template files (around line 68ish) you need to insert the following code. i would recommend setting up template overrides for this

    <?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) ) : ?>
    
            <?php do_action( 'bbp_theme_before_reply_form_tags' ); ?>
            <p>
                <label for="bbp_topic_tags"><?php _e( 'Tags:', 'bbpress' ); ?></label><br />
                <?php  echo displayTagElements(bbp_get_form_topic_tags(), bbp_get_user_role(get_current_user_id()), 'edit'); ?>
            </p>
    
            <?php do_action( 'bbp_theme_after_reply_form_tags' ); ?>
    
    <?php endif; ?>
    #161557
    23creative
    Participant

    you’re welcome mate. my code actually changed quite a bit form what I posted here. the tag list is pulled from wp-admin > Topics > Topic tags

    updated code below

    //change the seclected terms to string and return
    function restrict_topic_tags( $terms, $topic_id, $reply_id ) {
        if(isset($_POST['bbp_topic_tags'])){
            $bbp_topic_tags = filter_input(INPUT_POST, 'bbp_topic_tags', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
            return returnFormattedTags($bbp_topic_tags, $topic_id);
        }else{
            return $terms;
        }   
    }
    add_filter( 'bbp_new_reply_pre_set_terms', 'restrict_topic_tags' );
    
    //change the seclected terms to string and return
    function restrict_new_topic_tags( $topic_data ) {
       //$bbp_topic_tags = $data   = filter_input(INPUT_POST, 'bbp_topic_tags', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
       if(isset($_POST['bbp_topic_tags'])){
            $bbp_topic_tags = filter_input(INPUT_POST, 'bbp_topic_tags', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
            $topic_data['tax_input'] = array('topic-tag'=>checkTags($bbp_topic_tags)); 
       }
       return $topic_data;
    }
    add_filter( 'bbp_new_topic_pre_insert', 'restrict_new_topic_tags' );
    
    //change return the correct tag on a form error submission, we might need to go through the spam check here. But lets see how this goes
    function loadPostTagArray( $topic_tags ) {
       if( $topic_tags == 'Array'){
            if ( bbp_is_post_request() && isset( $_POST['bbp_topic_tags'] ) ) {
                $bbp_topic_tags = filter_input(INPUT_POST, 'bbp_topic_tags', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
                $topic_tags = returnFormattedTags($bbp_topic_tags); 
            }
       } 
       return $topic_tags;
    }
    add_filter( 'bbp_get_form_topic_tags', 'loadPostTagArray' );
    
    function returnFormattedTags($topicTags){
        foreach ($topicTags as $key => $topicTag){
          if($key > 0) $terms .= ', ';
          $terms .= esc_attr( strip_tags( $topicTag ) );
        }
       return $terms;
    }
    
    function checkTags($selectedTags){
        $tags = get_categories( array('hide_empty'=> 0,'taxonomy' => 'topic-tag'));
        $toReturn = array();
        foreach($tags as $tag){
            if (in_array($tag->name, $selectedTags)) {
               $toReturn[] = $tag->name;
            }
        }
        return $toReturn;
    }
    
    function displayTagElements($selectedTags, $userRole, $task){
        $html = array();
        $tags = get_categories( array('hide_empty'=> 0,'taxonomy' => 'topic-tag'));
        $selectedTagsArray = explode(', ', $selectedTags);
        if($userRole != 'bbp_participant' || $task != 'edit'){    
            $html[] = '<select class="chzn-select" multiple="multiple" name="bbp_topic_tags[]" id="bbp_topic_tags">';
                foreach($tags as $tag){
                    $selected = '';
                    if (in_array($tag->name, $selectedTagsArray)) {
                       $selected = 'selected="selected"';
                    }
                    $html[] = '<option '.$selected.' value="'.$tag->name.'">'.$tag->name.'</option>';
                }
            $html[] = '</select>';
        }else{
            $html[] = $selectedTags;
        }
        return implode('',$html);
    }
    #161552
    Nicolas Korobochkin
    Participant

    Hi. The ending / (trailing slash?) added automaticly if you setup something like /news/%POST_ID%/ on the WordPress permalinks page. And not be added if no slash at the end — /news/%POST_ID%. This works because I use user_trailingslashit() inside the code.

    BuddyPress group forums not supported yet. Something hardcoded inside and I not find the solution to this issue right now but I keep digging. 🙂

    Master
    Participant

    i find just remowe 'show_none' => __( '(No Forum)', 'bbpress' ), from form-topic.php

    #161547
    tylersoden
    Participant

    If anyone stumbles upon this thread and is interested in a css solution, here is the code I use. It goes in the ‘Appearance’ -> ‘Editor’ section on the wordpress control panel or in ‘~/<your theme folder>/style.css’:

    .bbp-template-notice.info { display: none; }

    #161538
    s1r0n
    Participant

    I need some help. I am trying to manually insert a topic into a forum. I’m doing from a different blog on the network however so I’m assuming I can’t use BBPRESSS functions to do so. anyway the code I have so far looks like this

     switch_to_blog(LP_SCHOOL_BLOG);
    
        	// Forum
    	$reply_data = array(
    		'post_parent'    => 0, // topic ID
    		'post_status'    => 'publish',
    		'post_type'      => 'topic',
    		'post_author'    => $current_user->ID,
    		'post_password'  => '',
    		'post_content'   => $post_content,
    		'post_title'     => "New Resource: " . $post->post_title,
    		'menu_order'     => 0,
    		'comment_status' => 'closed'
    	);
    
    	// Insert reply
    	$reply_id   = wp_insert_post( $reply_data );
    
            update_post_meta( $reply_id, '_bbp_author_ip' , get_user_ip() );
            update_post_meta( $reply_id, '_bbp_forum_id' , 2231 );
            update_post_meta( $reply_id, '_bbp_topic_id' , 0);
    //        update_post_meta( $reply_id, '_bbp_topic_id', (int) $topic_id );
            restore_current_blog();

    This code is correctly posting a topic. I can see the topic at the back end, and it looks exactly like any other topic, from the back end, but it is not appearing in the forum listing at the front end.Is there some additional bit of meta data that I have to insert? to get it to show up at the front end?

    TIA

    m

    #161527
    majecdad
    Participant

    hey @23creative Thanks for sharing your code. I’m interested in testing it to see if I can get it to work for my needs. Sorry for what may be a basic question, but where in the code do you place the names of the multiple tags that you want users to be forced choose from?

    Is it possible you show it in an example?

    Thanks a bunch.

    #161526
    Master
    Participant

    I fixed this problem change from form-topic.php

    <?php if ( bbp_current_user_can_access_create_topic_form() ) : ?>
    to
    <?php if ( is_user_logged_in() ) : ?>

    #161516
    Robkk
    Moderator

    @tonycntr

    you could remove some capabilities from some user roles

    https://wordpress.org/plugins/members/

    this guide will help find the user capabilies ( what they do is self explanatory)

    https://codex.bbpress.org/bbpress-user-roles-and-capabilities/

    as for a membership plugin s2 member and pmpPRO (its free) with its bbPress addon should be two good candidates.

    #161515
    Robkk
    Moderator

    sorry want on the past day

    this looks like the wrong CSS to use if the topic was too wide to me.

    .bbp-reply-content p {
    width : 580px !important ;
    }

    remove it so i could check it out.

    then i will be able to fix this issue and other one.

    #161514
    Robkk
    Moderator

    please read these two guides first , and hopefully they will help you

    https://codex.bbpress.org/import-forums/
    https://codex.bbpress.org/import-forums/simplepress/

    #161513
    Robkk
    Moderator

    should be very familiar to the other subscription link

    span#subscription-toggle a.subscription-toggle

    #161511

    In reply to: having problem

    Robkk
    Moderator

    @kellygree

    but when I try to register it direct me to my wordpress login page

    ive looked into this and its normal, its because the register form functionality isnt really finished

    https://bbpress.trac.wordpress.org/ticket/2137

    you can use the default WordPress registration pages if you want they are fine for user registration for all your users, and you could customize the default WordPress registration pages with some other plugins too.

    if you want dedicated front-end forms use a plugin like this

    https://wordpress.org/plugins/theme-my-login/

    our login shortcode [bbp-login] works fine though.

    #161502
    mrjarbenne
    Participant

    I found the culprit. I don’t know how I missed it before, but by default a registered user is added as a participant. This toggle was forcing me on the site, even when I removed myself.

    I can hack the plugin and set that as false by default. I’ll just need to remember to fix that every time the plugin updates, and I’ll need to let users know that they need to add a forum role to their users (which shouldn’t be a big deal).

    Looks like I can do that on bbpress/includes/admin/settings/line 532 changing the true to false.

    <input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php checked( bbp_allow_global_access( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_global_access' ); ?> />

    I can understand why it’s set this way. It does make the plugin work “out of the box” in a way that users would otherwise need to sort through what is already a very intricate settings panel.

    #161501
    wenlujon
    Participant

    it seems bbpress uses user_nicename to mention (AT) users, how to modify the code to change it to mention users through display_name (I can make sure each user has a unique display_name during signup).

    #161479
    Nicolas Korobochkin
    Participant
    1. Create folder bbpress-permalinks-with-id in wp-content/plugins dir.
    2. Download 1.0.3 version github . com / korobochkin/bbpress-permalinks-with-id/releases/tag/v1.0.3 (remove spaces bbPress forum doesn’t allow publish links)
    3. Unpack archive.
    4. Put plugin folder content into the bbpress-permalinks-with-id.
    5. Activate plugin.
    6. Flush rules by visiting /wp-admin/options-permalink.php page.

    And after this in all bbpress permalinks for topics and forums will be using ID’s instead of slugs.

    #161452
    w-sky
    Participant

    Yes, I added CSS code to change the width of two rows of the forum index:

    li.bbp-forum-topic-count,
    li.bbp-topic-voice-count,
    li.bbp-forum-reply-count,
    li.bbp-topic-reply-count {
    float: left;
    text-align: center;
    width: 12%;
    }
    
    li.bbp-forum-freshness,
    li.bbp-topic-freshness {
    text-align: center;
    float: left;
    width: 20%;
    }

    And also this, because the topic display was to wide too:

    .bbp-reply-content p {
    width : 580px !important ;
    }

    Maybe I could fix the problem here by also setting the width to 580px for the edit field, but I have no clue how.

    #161446
    Robkk
    Moderator

    @olivereggertsen

    it seems to work find on my end.

    i didnt manually add da_DK to the wp-config.php file though i just went to settings > general and changed the language.

    are you sure you did it correctly??

    make sure to follow these guides

    https://codex.bbpress.org/bbpress-in-your-language/
    https://codex.bbpress.org/bbpress-in-your-language/danish-dansk-da_dk/

    if you need any additional help reply back.

    Robkk
    Moderator

    You really are helpful, robkk!

    just going down the list haha

    span#favorite-toggle a.favorite-toggle
    span#subscription-toggle a.subscription-toggle

    make sure you have favorites and subscriptions activated in settings > forums

Viewing 25 results - 8,876 through 8,900 (of 32,505 total)
Skip to toolbar