Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1 through 25 (of 32,453 total)
  • Author
    Search Results
  • #246052

    In reply to: Topic to be approved

    Ricsca2
    Participant

    Is it because of this option I set by chance?

    Before a comment appears: Comment authors must have a previously approved comment.

    I also set “Keep a comment in queue if it contains 2 or more links (a common characteristic of comment spam is a large number of links).”

    and the post had 4 images loaded via code and HTML links.

    Are forum topics and comments treated as if they were WP comments?

    Thanks

    #246024
    agencenobilito44
    Participant

    Bonjour,

    J’appelle sur mon site :
    echo do_shortcode(‘[bbp-topic-index show="5" show_search="false"]‘);
    Seulement le moteur de recherche s’affiche quand même, avez-vous une idée ou une solution svp ?
    Merci

    I’m calling on my website:
    echo do_shortcode(‘[bbp-topic-index show="5" show_search="false"]‘);
    Only the search engine is still displayed. Do you have any ideas or solutions, please?
    Thanks

    Robin W
    Moderator

    For those who are less keen on code, or who install or already have

    bbp style pack

    then just go to

    dashboard>settings>bbp style pack>Topic/Reply Form

    and use option 6

    Ricsca2
    Participant

    Hi everyone,

    I’d like to share a very useful snippet for bbPress that I had a hard time finding on Google, but which can save a lot of time.

    For many communities it’s extremely helpful to have the “Notify me of follow-up replies via email” box checked by default. This way, users are automatically notified of new replies and are more likely to come back to the forum and engage in the discussion.

    Here is a simple solution that works on the latest WordPress + bbPress. Just add it to your theme’s functions.php or into a small custom plugin:

    
    // Auto-check the "Notify me of follow-up replies via email" box (topic + reply forms)
    add_action('wp_footer', function () {
        if (is_admin() || !function_exists('bbp_is_subscriptions_active') || !bbp_is_subscriptions_active() || !is_user_logged_in()) {
            return;
        }
        ?>
        <script>
        document.addEventListener('DOMContentLoaded', function () {
            var t = document.getElementById('bbp_topic_subscription');
            if (t && !t.checked) t.checked = true;
    
            var r = document.getElementById('bbp_reply_subscription');
            if (r && !r.checked) r.checked = true;
        });
        </script>
        <?php
    }, 99);
    

    With this snippet, whenever a logged-in user creates a new topic or reply, the subscription checkbox will already be checked by default.
    Of course, the user can still uncheck it if they don’t want notifications.

    This small trick makes it much easier to keep members engaged and ensures they don’t miss important replies.

    Hope it helps others too, since I believe this should be more widely documented!

    #245921
    Robin W
    Moderator

    but yes it’s fixed in 2.6.14

    // BuddyPress < 12.0 (deprecated code is intentionally included)
    		if ( function_exists( 'bp_core_get_user_domain' ) ) {
    			$url = array( bp_core_get_user_domain( $user_id ) );
    
    		// BuddyPress > 12.0 (rewrite rules)
    		} elseif ( function_exists( 'bp_members_get_user_url' ) ) {
    			$url = array( bp_members_get_user_url( $user_id ) );
    		}
    #245916
    Robin W
    Moderator

    Very briefly tested as I am on holiday tomorrow, but try this

    $r = array(
    		'post_type'              =>bbp_get_reply_post_type(),   
    		'post_parent'            => $topic_id,  
    		'author__not_in' => array( $author_id)
    		);
    	$reply_posts = new WP_Query($r); 
    	$count = $reply_posts->post_count;
    thinlizzie
    Participant

    Hi Robin,

    I’m writing some code to pay a little “reward points” bonus to the author of a forum topic, when that topic receives X number of replies.
    All works fine, hooking to bbp_new_reply.
    But I would like to exclude any replies by the author themself from the total replies count.
    Total replies count is currently bbp_get_topic_reply_count( $topic_id )
    So I need to subtract author_own_replies from that total.

    I have $topic_id, $author_id, $reply_id, $forum_id

    Any easy way to achieve this?

    I’m trying to avoid SQL queries.

    #245910
    internationaljack
    Participant

    Sure!

    	/**
    	 * Reads entire file into a string.
    	 *
    	 * @since 2.5.0
    	 *
    	 * @param string $file Name of the file to read.
    	 * @return string|false Read data on success, false if no temporary file could be opened,
    	 *                      or if the file couldn't be retrieved.
    	 */
    	public function get_contents( $file ) {
    		$tempfile   = wp_tempnam( $file );
    		$temphandle = fopen( $tempfile, 'w+' );
    
    		if ( ! $temphandle ) {
    			unlink( $tempfile );
    			return false;
    		}
    
    		if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {
    			fclose( $temphandle );
    			unlink( $tempfile );
    			return false;
    		}
    
    		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
    		$contents = '';
    
    		while ( ! feof( $temphandle ) ) {
    			$contents .= fread( $temphandle, 8 * KB_IN_BYTES );
    		}
    
    		fclose( $temphandle );
    		unlink( $tempfile );
    
    		return $contents;
    	}

    Line 146 is if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {

    #245907
    internationaljack
    Participant

    Thank you for helping me interpret that!

    This is what was on that line:
    <p class="logo_tagline"><?php bloginfo(description); ?></p>

    I added single quotes to 'description' and now the forums fully load (when FS_METHOD is set to direct). That line was basically the only difference between the original bbpress.php and the child theme’s copy of bbpress.php.

    Unfortunately, that fix only works with FS_METHOD set to direct. I need it set to ftpext so WordPress requests FTP credentials (for things like plugin updates), because otherwise WP doesn’t have write permission.

    When I change FS_METHOD to ftpext, the forum pages start giving me the ol’ “There has been a critical error on this website” message.
    The log gives me this:
    [08-Aug-2025 17:23:55 UTC] PHP Fatal error: Uncaught TypeError: ftp_fget(): Argument #1 ($ftp) must be of type FTP\Connection, null given in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-ftpext.php:146

    That’s not a bbPress file, so I think I’ll have to talk with our webhost about this.

    Thanks for your help!

    Robin W
    Moderator

    This has been removed probably because it no longer worked.

    Since bbpress just uses WordPress login, If you google ‘modal popup login wordpress’ you’ll find both code and plugins that do this

    #245895
    Robin W
    Moderator

    ok the fatal error is

    [07-Aug-2025 22:39:39 UTC] PHP Fatal error: Uncaught Error: Undefined constant "description" in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada-Child-Theme/bbpress.php:22

    so this is a file called bbpress.php which sites in you child theme.

    I suspect that this is a file that contains amendments to bbpress that someone has made, but without knowing why that file is there and what it does, I cannot say further

    yt
    Participant

    Hello everyone

    My site was created with WordPress 6.8.2 and BBPress 6.2.14 with the WordPress 2025 theme block template.

    In the BBPress documentation titled: “Layout and functionality – Examples you can use” at:

    Development & Updates

    in line 12 it says:

    12. Add a modal login (pop-up) window
    This is quite neat and the instructions add it to the menu and, if necessary, add the login/logout.

    The login looks like this
    https://buddypress.org/wp-content/uploads/53/2014/02/modal-login3-300×144.jpg

    There are different styles available and you can have your own style.

    Instructions can be found here:
    https://codex.bbpress.org/modal-login-in-a-menu/

    I tried to access it, but unfortunately the link gives an error of
    Error 404 – Destination Not Found.

    Please advise on how I can enable the above mentioned forum registration and login pop-up in my site’s forum?

    Thank you in advance for your help.

    #245891
    internationaljack
    Participant

    When I try to access a forum, I only see the site header (the rest of the page is blank). This is what shows up in my debug.log:

    [07-Aug-2025 22:39:33 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:34 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:39 UTC] PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada/includes/class-avada-layout-bbpress.php on line 219
    [07-Aug-2025 22:39:39 UTC] PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada/includes/class-avada-layout-bbpress.php on line 219
    [07-Aug-2025 22:39:39 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "description" in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada-Child-Theme/bbpress.php:22
    Stack trace:
    #0 /var/www/vhosts/[SITEURL]/httpdocs/wp-includes/template-loader.php(106): include()
    #1 /var/www/vhosts/[SITEURL]/httpdocs/wp-blog-header.php(19): require_once('/var/www/vhosts...')
    #2 /var/www/vhosts/[SITEURL]/httpdocs/index.php(17): require('/var/www/vhosts...')
    #3 {main}
      thrown in /var/www/vhosts/[SITEURL]/httpdocs/wp-content/themes/Avada-Child-Theme/bbpress.php on line 22
    [07-Aug-2025 22:39:39 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173
    [07-Aug-2025 22:39:47 UTC] PHP Warning:  chmod(): Operation not permitted in /var/www/vhosts/[SITEURL]/httpdocs/wp-admin/includes/class-wp-filesystem-direct.php on line 173

    The above is with this in wp-config.php:
    define('FS_METHOD', 'direct');

    Our sites are normally set to define('FS_METHOD', 'ftpext'); but that produces a much longer error string in the log and a “this site has experienced a critical error” message in the browser.

    Our prod site is on PHP 7.4.33 and doesn’t have any issues in either FS_METHOD mode. Did PHP 8 change something that affected filesystem access?

    Notes:
    – This is a multisite with a bbPress forum on almost all sites.
    – Our theme, Avada, runs fine on our other dev site with PHP 8.4.

    #245885
    manojmohandev
    Participant

    line #956,

    // Only update if reply is published
    if ( ! bbp_is_reply_pending( $reply_id ) ) {

    As per the comment, it should check if reply is published. But this condition will be true even if the reply is marked as spam. Instead it should use if ( bbp_is_reply_published( $reply_id ) ). Same thing I have observed for topic as well. If topic is marked as spam by akismet, the last active parameters reflects the spam topic instead of last published topic.

    #245868
    yt
    Participant

    Hello @robin-w

    The code is tested and works fine. Thank you for that.

    It seems that the code needs two modifications to be converted into a complete code. These two modifications are:

    1- Modification related to the user
    Absolutely directing the logged in user to the first page of the site is not useful in most cases, because

    Suppose the user has entered a forum topic and wants to reply to it. For this purpose, he enters the forum by entering his user information. In the default WordPress mode, the user who is on the current page is considered a logged in user and can send a reply

    However, with the above code, the user is redirected from the current page to the first page of the site and must return to the initial page of the topic in question with a few clicks. This causes user annoyance and increases the bounce rate from the forum.

    Therefore, the code needs to be modified so that the user on the current page (meaning any page of the forum or site that has a comment) is logged in on the same page as the current user after entering his user information and logging in, but at the same time does not have access to the counter.

    2- Correction related to the site and forum administrator
    The same problem as above is true for the administrator. For example, the administrator enters the forum and wants to create a topic or reply to a topic, so he enters the login information. In the default WordPress mode, he is considered logged in on the current page, but at the same time, the WordPress admin bar is displayed at the top of the forum or site, which means he has access to the counter.

    However, with the above code, the administrator is redirected from the current page to the counter, which should return to the original current page with a few clicks, just like the same user.

    Is it possible to modify the code as described?

    Thank you very much in advance for your valuable help.

    yt
    Participant

    Hello everyone

    A code snippet is needed to suspend the publication of topics and replies submitted by forum members until the forum administrator approves (something similar to what is in place for site comments until the administrator approves).

    A code that can be run in a BBPress function file or a WPCode plugin php snippet file and work.

    Thanks in advance for your help

    yt
    Participant

    Hi @robin-w
    The code works fine.
    Thanks for your help.

    jennypins
    Participant

    What Happened to “Views” in bbPress 2.6.14?
    In earlier versions of bbPress, Views were visible as a menu item in the WordPress admin under Forums > Views.

    In version 2.6.14, the admin menu link to Views was removed by default as part of bbPress cleanup and streamlining.

    However, the Views themselves still exist — they’re just hidden from the admin menu unless you’re actively using or registering them.

    How to Restore the “Views” Menu
    You can manually re-enable the Views admin menu by adding a small code snippet to your theme’s functions.php file or a custom plugin:
    add_action( ‘bbp_admin_menu’, function() {
    add_submenu_page(
    ‘edit.php?post_type=forum’,
    ‘Topic Views’,
    ‘Views’,
    ‘manage_options’,
    ‘edit.php?post_type=topic_view’
    );
    });

    Robin W
    Moderator

    Try

    #bbpress-forums .status-closed,
    #bbpress-forums .status-closed a {
    color: #aaa !important;
    background-color: none !important;
    }
    #245833
    Robin W
    Moderator

    now corrected in codes, to this

    /**
    * WordPress function for redirecting users on login based on user role
    */
    function my_login_redirect( $url, $request, $user ){
    if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
    if( $user->has_cap( 'administrator' ) ) {
    $url = admin_url();
    } else {
    $url = home_url();
    }
    }
    return $url;
    }
    add_filter('login_redirect', 'my_login_redirect', 10, 3 );
    yt
    Participant

    Hello everyone

    My site is using the latest WordPress 6.8.2 with WordPress 2025 theme and BBPress community

    To change the color of closed topics in

    13. Preventing closed topics from going grey

    At address:

    Layout and functionality – Examples you can use

    The following code:

    #bbpress-forums .status-closed,
    #bbpress-forums .status-closed a {
    color: #aaa !important;
    }

    is introduced.

    I put it in the css snippet of WPCode plugin. but the code doesn’t work.

    Can anyone help me fix the problem?

    Thanks

    #245831
    yt
    Participant

    Hi everyone

    My site is using the latest WordPress 6.8.2 with WordPress 2025 theme and BBPress community

    In
    27. Custom Redirect After Login

    At address

    Layout and functionality – Examples you can use

    The following dual-purpose redirect code:

    /**
    * WordPress function for redirecting users on login based on user role
    */
    function my_login_redirect( $url, $request, $user ){
    if( $user && is_object( $user ) && is_a( $user, ‘WP_User’ ) ) {
    if( $user->has_cap( ‘administrator’ ) ) {
    $url = admin_url();
    } else {
    $url = home_url();
    }
    }
    return $url;
    }
    add_filter(‘login_redirect’, ‘my_login_redirect’, 10, 3 );

    It is introduced that I have it in the php sippet file of the WordPress plugin code but I am getting the error

    Your changes are saved but your snippet was deactivated due to an error, please check the syntax and try again. Error message: syntax error, unexpected token ;

    It seems that there is a problem with the code.

    Can anyone help to fix the problem?

    #245819
    Robin W
    Moderator

    Yes, this widget is no longer available.

    For you if you have the style pack plugin, you can use the bsp-profile shortcode instead

    [bsp-profile label="amend profile/password" edit="true"]

    You can simply add a shortcode block after the login widget.

    bbp style pack

    #245810
    #245797
    yt
    Participant

    Thanks for your reply

    I mean the twentytwentyfive WordPress theme block template.

    To view live errors, you can:

    1- By entering the forum home page address

    https://ghazavatonline.ir/forums/

    In the forum search form, enter a desired phrase and then press enter. Instead of displaying the search results, you will see in the header the error:

    Warning: Undefined array key “archive” in /home/ … /public_html/wp-includes/block-template.php on line 180

    Warning: Undefined array key “archive” in /home/ … /public_html/wp-includes/block-template.php on line 180

    2-Also, when you click on any of the tags that have topics assigned to them, instead of displaying the tags, the above error code is displayed and no topics are displayed

    For this, visit the address

    شکایت از قاضی دادگاه به علت عوض کردن جای متهم ها

    Click on the tag “تخلفات انتظامی قضات”

    Or go directly to the link

    https://ghazavatonline.ir/forums/topic-tag/disciplinary-breaches-of-judges/

    to see the same errors in the header and that no topic associated with the selected tag is displayed.

    Of course, it should be noted that the above errors are only generated when the twentytwentyfive block template is activated

    But when the twentytwentyfour and twentytwentythree templates are activated, they are not generated and work without problems.

Viewing 25 results - 1 through 25 (of 32,453 total)
Skip to toolbar