Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 251 through 275 (of 32,294 total)
  • Author
    Search Results
  • #238919
    Robin W
    Moderator

    for completeness look at

    \bbpress\includes\topics\functions.php line 96

    This is what bbpress does to create a new topic.

    on line 378 it has a hook

    do_action( 'bbp_new_topic',......

    which is used in

    bbpress\bbpress\includes\core\actions.php

    Line 206: add_action( 'bbp_new_topic',  'bbp_update_topic', 10, 5 );
    Line 241: add_action( 'bbp_new_topic',    'bbp_notify_forum_subscribers', 11, 4 );
    Line 287: add_action( 'bbp_new_topic',        'bbp_increase_forum_topic_count' );
    Line 327: add_action( 'bbp_new_topic',     'bbp_increase_user_topic_count' );
    Line 346: add_action( 'bbp_new_topic', 'bbp_update_topic_engagements', 20 );
    Line 350: add_action( 'bbp_new_topic', 'bbp_update_topic_voice_count', 30 );

    to call the other functions that update the meta, and thus get the topic to show.

    #238918
    rilliencot
    Participant

    Figured it out.

    It was an issue with the post meta content. For topics to appear in forums, they apparently need to have a ‘_bbp_last_active_time’. I was able to add this by adding the line add_post_meta($topic_id, '_bbp_last_active_time', date('Y-m-d H:i:s')); right below the $topic_id = wp_insert_post($topic_args); line in the php file (with the date function getting the current datetime and returning it in the proper format).

    #238917
    rilliencot
    Participant

    I’m also discovering that the when I create a new topic via the standard route, the following post meta fields are generated in the wp_postMeta table for the topic:

    edit_lock
    edit_last
    bbp_forum_id
    bbp_author_ip
    bbp_last_reply_id
    bbp_last_active_id
    bbp_last_active_time
    bbp_reply_count
    bbp_reply_count_hidden
    bbp_voice_count

    However, these do not get generated when I create a topic through my API. I have a feeling this is the issue. I’m not really sure what I’m supposed to do about this though. I notice the bbp_forum_id field is included in there. Should I be using this to set that field instead of shoehorning through ‘post_parent’ in an additional plugin?

    #238915
    rilliencot
    Participant

    WordPress Version: 6.4.2
    bbPress Version: 2.6.9
    Link to site: Unavailable (Site created using LocalWP and still hosted locally)

    When I create topics through the standard frontend or backend, the new topic shows up in the forum perfectly.

    However, if I create a new topic using a plugin extension I’ve cobbled together, the new topic does not show up on the front end of the website (despite it being created and visible on the back end).

    The plugin written in php is as follows (thanks to work from here and here):

    
    <?php
    /**
     * Plugin Name:       bbPress API
     * Description:       Exposing the bbPress post types to WP API.
     * Author:            Rillien Cot
     * Version:           1.3.0
     */
    
    /**
     * Add REST API support to an already registered post type.
     */
    add_action('init', 'register_bbp_post_types', 25);
    
    function register_bbp_post_types() {
        global $wp_post_types;
    
        $post_type_name =  bbp_get_reply_post_type();
        if (isset($wp_post_types[$post_type_name])) {
            $wp_post_types[$post_type_name]->show_in_rest = true;
            $wp_post_types[$post_type_name]->rest_base = $post_type_name;
            $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
        }
        $post_type_name =  bbp_get_topic_post_type();
        if (isset($wp_post_types[$post_type_name])) {
            $wp_post_types[$post_type_name]->show_in_rest = true;
            $wp_post_types[$post_type_name]->rest_base = $post_type_name;
            $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
        }
        $post_type_name =  bbp_get_forum_post_type();
        if (isset($wp_post_types[$post_type_name])) {
            $wp_post_types[$post_type_name]->show_in_rest = true;
            $wp_post_types[$post_type_name]->rest_base = $post_type_name;
            $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
        }
    
        // Add custom REST API endpoint for creating bbPress topic
        add_action('rest_api_init', 'create_bill_endpoint');
    }
    
    function create_bill_endpoint() {
        register_rest_route('pnyx/v2', '/bill/', array(
            'methods' => 'POST',
            'callback' => 'create_bill',
        ));
    }
    
    function create_bill($data) {
        // Extract necessary data from the request
        $forum_id = $data['forum_id'];
        $topic_title = $data['topic_title'];
        $topic_content = $data['topic_content'];
        $bill_id = $data['bill_id'];
    
        // Create a new bbPress topic
        $topic_args = array(
            'post_title' => $topic_title,
            'post_content' => $topic_content,
            'post_type' => bbp_get_topic_post_type(),
            'post_status' => 'publish',
            'post_parent' => $forum_id, // Set the post_parent to the forum ID
        );
    
        $topic_id = wp_insert_post($topic_args);
    ?>
    

    Basically, it exposes the Forum, Topic, and Reply post types from bbPress to standard wp-json/v2 namespace and then adds an additional endpoint (‘create_bill’) which allows me to add a new topic and associate it with a forum via ‘post_parent’. (I wonder if this is where the problem is?)

    I create a new topic using the following python script:

    
    import requests
    import json
    
    # Set WordPress API authentication details
    username = "*******"
    password = "**********************"
    auth = requests.auth.HTTPBasicAuth(username, password)
    
    # Values for new post data
    new_post_data = {
        "forum_id": 40, # <- This is a valid post id of a forum.
        "topic_title": "New API Topic Title",
        "topic_content": "Lorem ipsum content for the new topic"
    }
    
    # Make the POST request to create a new post
    wordpress_api_url = "http://pnyx.local/wp-json/pnyx/v2/bill/"
    response = requests.post(
        wordpress_api_url,
        auth=auth,
        headers={
            'Content-Type': 'application/json',
        },
        data=json.dumps(new_post_data)
    )
    

    The topic is created, and I can see it in Dashboard>>Topics>>All Topics. And I can view it by going directly to the link associated with it, but I can’t see it on the actual frontend of the forum.

    I’ve deactived all other plugins and I’m still getting this issue. The only differences between the two (as far as I can tell) are the Author IP (API created topics leave this field blank, standard fills it with 127.0.0.1) and the number of voices (API created topics have 0, standard created topics have 1). All the other settings seem identical (visibilty = public, type = normal, status = open).

    Any insights as to what I’m missing and how to rectify the situation are greatly appreciated, thanks!

    #238914
    Robin W
    Moderator

    Thanks, I’ve just tested your scenario above, and yes that is a bug.

    I am not a bbpress author, just someone who helps out here.

    Strangely that metabox doesn’t actually let you change the subscribers, it simply lists them, not sure why 🙂

    if you are using

    bbp style pack


    then I’ve included a fix for this in version 5.7.8.

    You can also add comprehensive subscription management functionality for the backend from the ‘subscriptions management’ tab.

    Otherwise you could add this code:

    
    add_action ('bbp_subscriptions_metabox' , 'rew_set_hidden_subscribers' ) ;
    add_action ('bbp_topic_attributes_metabox_save' , 'rew_save_subscriptions', 10 , 2) ;
    
    function rew_set_hidden_subscribers ($post) {
    	// Get user IDs
    	$user_ids = bbp_get_subscribers( $post->ID );
    	$list = implode(",",$user_ids); 
    
    	// Output
    	?>
    	<input name="rew_topic_subscription" id="rew_topic_subscription" type="hidden" value="<?php echo $list; ?>" />
    	<?php
    }
    
    function rew_save_subscriptions ( $topic_id, $forum_id ) {
    	// Handle Subscriptions
    	if ( bbp_is_subscriptions_active() && ! empty( $_POST['rew_topic_subscription'] )) {
    		//update_option ($subscriptions)
    		$subscriptions = explode(",", $_POST['rew_topic_subscription']);
    		foreach ($subscriptions as $subscription_id ) {
    			// Check if subscribed and if so do nothing
    			if (bbp_is_user_subscribed( $subscription_id, $topic_id )) continue;
    			else {
    			bbp_add_user_subscription( $subscription_id, $topic_id );
    			}
    		}
    	}
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    #238896
    itdahdev
    Participant

    Next issue, found a missing import field “_bbp_topic_voice_count” and i’m pretty sure, thats counted participants were ment. But in woltlap db thread tbl is no colum, so i think, i’ve could du it with a sql query like this:

    SELECT COUNT(DISTINCT po.userID) as participants
    FROM wbb1_thread th
    INNER JOIN wbb1_post po
    ON th.threadID = po.threadID
    WHERE th.threadID = 2086

    The sql query in phpmyadmin works as mentioned. So i copied a piece of code from another importer and customized it like this (? for parts i have no clou):

    $this->field_map[] = array(
    ‘from_tablename’ => ‘wbb1_thread’,
    ‘from_fieldname’ => ‘?’,
    ‘join_tablename’ => ‘wbb1_post’,
    ‘join_type’ => ‘INNER’,
    ‘join_expression’ => ‘USING (?) WHERE wbb1_thread.?= wbb1_post.?’,
    ‘to_type’ => ‘topic’,
    ‘to_fieldname’ => ‘_bbp_topic_voice_count’
    );

    But i’ve no clou, how to bring the sql in the right way for the import, missing manuals from bbPress, to understand he possibilities.

    Anybody firm in this?

    #238888
    milimo1
    Participant

    I added codes on a page for my forum and included topics and a forum that displays just fine. The problem or headache starts when I click on any of the links to the shortcodes. Just a blank page is all that shows. I’ve tried searching for help but to no avail. I’ve seen in tutorials that the links shown work and lead you to more info when you click on topics or the forums. Kindly help me.

    WordPress version 6.4.2, bbPress Version 2.6.9

    Links to Problem Pages
    Link to blank page after clicking forum
    Link to forum and topics page

    #238882
    Robin W
    Moderator

    I’d suspect that php 8.x is the issue.

    New versions of php get more strict in code requirements, and arrays are one that php 8.x got nasty with.

    I’d suggest (if you can) changing to php 7.x whilst you do the import – after that you can revert to php 8.x.

    #238818
    prokops
    Participant

    Here is a functions / snippet code version for anyone else looking:

    function my_forums_dropdown_shortcode() {
        // Start buffering output
        ob_start();
    
        // Dropdown container
        echo '<select id="forums-dropdown" onchange="location = this.value;">';
        
        // Forum loop
        if ( bbp_has_forums() ) :
            while ( bbp_forums() ) : bbp_the_forum();
                $forum_permalink = bbp_get_forum_permalink();
                $forum_title = bbp_get_forum_title();
                echo "<option value='{$forum_permalink}'>{$forum_title}</option>";
            endwhile;
        else :
            // No forums found
            bbp_get_template_part( 'feedback', 'no-forums' );
        endif;
    
        // Close the dropdown
        echo '</select>';
    
        // Return the buffer contents
        return ob_get_clean();
    }
    add_shortcode('forums_dropdown', 'my_forums_dropdown_shortcode');
    

    Just paste in [forums_dropdown] where you want output.

    #238793
    nitrameon
    Participant

    Hello everyone,

    I use the Divi theme builder with BBPress and Buddypress to create a forum.

    I created pages and used shortcodes to customize the visual aspect of my forum.

    I’ve created numerous sub-forums (over 100) that are supposed to appear in the main forum. (I have limited the display to 50).

    However, when I go to the main forum, the first 50 are displayed, but no pagination allows me to see the other 50! I’ve searched all over the internet but haven’t found any answers.

    Thank you for your help.

    Nono

    #238792
    Robin W
    Moderator

    I’ve done a bit more investigation

    It looks like this code is only used if you have passwords that are not to the WordPress encryption, which would usually be after you have done an conversion to bbpress from a previous forum.

    Is this the case?

    #238776

    In reply to: Using iframe tags?

    meetarnav
    Participant

    How can I get the “participant” role to post iframes please? It is quite critical for my forum. If not that, I tried a plugin that achieves the same effect – however that is only working for Admins not for any other member – how do I enable “participants” to use the same short codes as admin or post iframes? Thanks.

    #238760
    meetarnav
    Participant

    Was this ever resolved. I have the same combination RPB and bbPress. The codes work for Keymaster but not foe Participant. Also, they don’t show pgn and fen as tags in the options on the editor – one has to type them in manually.

    #238755
    peq42
    Participant

    I’m running BBPress on wordpress 6.4.2 and PHP 8.3 and I’ve been getting the following deprecation warning:

    PHP Deprecated: Creation of dynamic property BBP_Admin::$forums is deprecated in /home/peq42/www/wp-content/plugins/bbpress/includes/admin/forums.php on line 793

    if possible, I’d like the devs to look into it

    #238712
    Robin W
    Moderator

    Thanks.

    Whilst I am not a bbpress author, adding fixes for themes which do not work with bbpress would require adding code for 200,000 bbpress users of whom only very small proportion use Hello Elementor, and then supporting this against any changes that Elementor do. There are other themes that also don’t work with bbpress and doing this for all these could add a mountain of work.

    But yes, I’m glad to add the link to this thread to help others

    Hello Elementor bbPress fix

    I will also be adding support for this into my style pack plugin in the new year

    bbp style pack

    #238711
    Robin W
    Moderator

    Thanks.

    Whilst I am not a bbpress author, adding fixes for themes which do not work with bbpress would require adding code for 200,000 bbpress users of whom only very small proportion use Hello Elementor, and then supporting this against any changes that Elementor do. There are other themes that also don’t work with bbpress and doing this for all these could add a mountain of work.

    But yes, I’m glad to add the link to this thread to help others

    Hello Elementor bbPress fix

    I will also be adding support for this into my style pack plugin in the new year

    bbp style pack

    #238706
    fasirathore
    Participant

    I’m using Hello Theme, unfortunately hello theme is not showing forums on my page by using forums index shortcode.
    When I switch to Astra theme or Nova themes, forum index displays properly.

    (I might be changing themes temporarily so forums might display if im on other themes but https://forextradingcommunity.com/forums/ is my forums link on my site.)

    I have contacted Hello Theme Support and they have responded as below:
    “I will have this raised but we suggest you report this issue to the plugin authors so they can check and they can open an issue on our Github account, so our developers and the plugin author can communicate”

    How can we resolve it?

    #238705
    fasirathore
    Participant

    I’m using Hello Theme, unfortunately hello theme is not showing forums on my page by using forums index shortcode.
    When I switch to Astra theme or Nova themes, forum index displays properly.

    (I might be changing themes temporarily so forums might display if im on other themes but https://forextradingcommunity.com/forums/ is my forums link on my site.)

    I have contacted Hello Theme Support and they have responded as below:
    “I will have this raised but we suggest you report this issue to the plugin authors so they can check and they can open an issue on our Github account, so our developers and the plugin author can communicate”

    How can we resolve it?

    #238676

    In reply to: Abandoned?

    Swiss-Cheese
    Participant

    Thank you @robin-w for your kind answer. I appreciate your time to look into this question and your diligence in answering people’s questions. It seemed this topic went in a different direction than I was expecting/asking, but perhaps I’m misunderstanding everyone’s answers? According to the security plugin WordFence documentation on their knowledge base it says the issue with bbPress is:

    Plugin appears to be abandoned
    This scan result means that a plugin has not been updated in 2 years or more. This can be a problem because it means that the plugin author has not made any changes for a long period of time. Sometimes that means it will not be fully compatible with newer WordPress versions, reported bugs may not be fixed, and new security issues might not be addressed.

    The scan result also shows if this plugin has a known security issue that has not been fixed. If that is the case, it is recommended that you remove the plugin as soon as possible, and replace it with a different plugin if you need the same functionality.

    There are two types of alerts for abandoned plugins, “Medium” and “Critical”. An abandoned plugin will generate a Medium alert. If the plugin also has unpatched security vulnerabilities, the scan result will be Critical. Plugins that are abandoned should be evaluated in terms of what risk they may pose. Unless you know that the code in the plugin is safe, you should start looking for a replacement. Plugins with unpatched vulnerabilities should always be removed.

    When I read this guideline from WordFence and look at the bbPress website, as well as reading what WordPress says about it and what information about bbPRess displays inside my dashboard of the install, I’m not certain which instruction to follow. Should I consider it abandoned? Well, someone came here and answered my question named moderator and other people also visited this thread and commented who seemed to assume my question was a PHP compatibility question (i don’t know, is my question a PHP compatibility issue i’ve yet to discover?) so if people are actively reading a support thread that’s not “abandoned” in the sense people are here interacting still. But abandoned where coders who are behind the coding of bbPress watching developments and using the best security practices and applying them? I’m not certain and am not sure how to decide that info without posting again to ask. As a non-coding person I have no way of knowing without asking.

    Is bbPress still in development, being monitored and updated by careful coders who look over it, or is the core code maintenance abandoned with some core enthusiasts who are still using it here interacting but not coders who know what’s what in the code? Unfortunately, I don’t read code. I am not a coder. So i have no way of knowing.

    #238590
    artmuns
    Participant

    @lmstearn: Thanks for that info on the php code.

    Here’s some info I found previously on this error (but you probably already knew this).

    The ‘Are you sure you want to do this? ‘ error usually appears when nonce verification fails, and the most likely candidates for causing this error are plugins and themes not using this feature properly. Nonces are unique keys that add a security layer to protect WordPress URLs, forms, and Ajax calls from abuse.

    https://www.google.com/search?q=are+you+sure+you+want+to+do+that+error+wordpress

    #238588
    robfaich
    Participant

    There’s bbP last post, bbP private groups, bbP Quote, bbP shortcodes as well as bbp style pack.

    #238585
    robfaich
    Participant

    Thanks for that. But this is quite confusing, the form I used was copied from dashboard>settings>shortcodes>additional shortcodes.

    #238582
    Robin W
    Moderator

    that shortcode is from bbp-style-pack plugin and should read

    [bsp-display-topic-index show='5' forum ='10,11,12']

    note bsp-display… not bbp-display…

    bbp style pack

    for details, go to

    dashboard>settings>bbp style pack>shortcodes

    #238571
    lmstearn
    Participant

    @artmuns: Totally acknowledge the user problem with expired pages causing this over here, and certainly copying the post-text is the first line of defence, just curious as to what it was in the superseded code that cached the text.

    Maybe the following,

    add_filter( 'bbp_verify_nonce_request_url', 'my_bbp_verify_nonce_request_url', 999, 1 );
    function my_bbp_verify_nonce_request_url( $requested_url )
    {
        return 'your_URI' . $_SERVER['REQUEST_URI'];
    }

    Now the functions.php has been dropped from Twenty Twenty Two and onwards, so might not be possible in the theme, could be a separate plugin, or a request for a cache module.

    For caching, use LiteSpeed over here, just added into the ESI Cache section these:

    bbp_verify_nonce_request
    wp_verify_nonce

    Not sure if they are correct, will post back if not. 🙂

    #238559
    robfaich
    Participant

    Shortcode actually used: [bbp-display-topic-index show=’15’ forum =’283,285,515,523,1159,21099′]

Viewing 25 results - 251 through 275 (of 32,294 total)
Skip to toolbar