Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 651 through 675 (of 32,358 total)
  • Author
    Search Results
  • #234844
    rinh
    Participant

    I appreaciate it though 🙂

    I realised I have a another problem. Is there any way to get the Recent Topics and Recent Replies widget to work in block editor, or get them to appear some other way for example shortcode? I didn’t realise until now that widgets don’t work in block editor.

    Thank you in advance.

    #234841
    rinh
    Participant

    Unfortunately I don’t think any of them is close or can just be cloned.

    [bbp-forum-index] – This one works well and can add the forum root anywhere.

    But then there’s Forums or Categories, Sub forums and topics/replies themselves. These pages seem to all be seen as ‘posts’ by WordPress, why making a posts template worked in Elementor for all of them. FSE templates seem to ignore bbPress entirely though.

    [bbp-single-forum id=$forum_id] – This one do make it possible to add single forums anywhere, but not if they’re inside a forum Category. Would also need one page for each forum which would get a little crazy. I don’t know if this one could be tweaked into something more advanced.

    What would be needed is shortcodes for displaying forum Category pages in general, as well as their sub forum pages where the topics are listed. And then all the topic/replies pages too.

    All that sound too difficult to be honest.

    #234837
    Robin W
    Moderator

    presume you are familiar with all these

    Shortcodes

    #234836
    rinh
    Participant

    Oh yes, I use the plugin to be able to display the forum in block themes. Thank you for the plugin by the way and all the work you do on them and this forum 🙂

    This is more about I’d like to put the forum in templates to be able to put additional content, for example I put a welcome message/info as well as a custom made sidebar in the Elementor template.

    I suppose there’s no shortcodes for displaying forums (other than root) as well as one for all topics? 😛

    I can totally understand avoiding getting too deep into FSE. I really appreciate it too, it’s like a mini theme builder. The learning curve do feels steep though.

    #234835
    Robin W
    Moderator

    my style pack has some code that fixes (sort of) FSE themes

    install

    bbp style pack

    once activated, navigate to

    dashboard>settings>bbp style pack, and you should see the first tab called ‘Theme Support’ – if you don’t see this, come back.

    In that tab, select

    Enable Theme Support

    and save

    The forums should then display

    If you want to look at code, then download the plugin to your computer and find

    \bbp-style-pack\trunk\includes\functions_theme_support.php

    I’m trying to avoid getting too deeply into FSE – I find it annoying, but appreciate that I am old and ludite, and that many find it fine or even great 🙂

    #234834
    rinh
    Participant

    Hi
    I’m looking into the possibility to move a community site from using Elementor Pro to WordPress own Full Site Editing and block theme.

    I’m curious if anyone has figured out how to apply templates to the forums and topics themselves. The forum root works fine though because it has a shortcode.

    In Elementor I worked it out by making a single post template and then exclude posts and custom post types from it, but in FSE it doesn’t seem possible to apply any templates to bbPress at all.

    Thank you in advance

    #234816
    Robin W
    Moderator

    I spent a couple of hours yesterday hunting down the issue.

    This code fixes it :

    add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ;
    
    function astra_bbpress_fix ($value) {
    	if( class_exists( 'bbpress' ) ) {
    		if (bbp_is_single_user()) return false ;
    		if (bbp_is_search()) return false ;
    	}
    return $value ;
    }

    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

    #234815
    Robin W
    Moderator

    I spent a couple of hours yesterday hunting down the issue.

    This code fixes it :

    add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ;
    
    function astra_bbpress_fix ($value) {
    	if( class_exists( 'bbpress' ) ) {
    		if (bbp_is_single_user()) return false ;
    		if (bbp_is_search()) return false ;
    	}
    return $value ;
    }

    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

    #234814
    Robin W
    Moderator

    I spent a couple of hours yesterday hunting down the issue.

    This code fixes it :

    add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ;
    
    function astra_bbpress_fix ($value) {
    	if( class_exists( 'bbpress' ) ) {
    		if (bbp_is_single_user()) return false ;
    		if (bbp_is_search()) return false ;
    	}
    return $value ;
    }

    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

    #234811
    Robin W
    Moderator

    Apologies for the delay is responding to this.

    Assuming you are ok with FTP, then

    find
    wp-content/plugins/bbpress/templates/default/bbpress/form-anonymous.php

    transfer this to your pc and edit to remove

    <p>
    			<label for="bbp_anonymous_email"><?php esc_html_e( 'Mail (will not be published) (required):', 'bbpress' ); ?></label><br />
    			<input type="text" id="bbp_anonymous_email"   value="<?php bbp_author_email(); ?>" size="40" maxlength="100" name="bbp_anonymous_email" />
    		</p>
    
    		<p>
    			<label for="bbp_anonymous_website"><?php esc_html_e( 'Website:', 'bbpress' ); ?></label><br />
    			<input type="text" id="bbp_anonymous_website" value="<?php bbp_author_url(); ?>" size="40" maxlength="200" name="bbp_anonymous_website" />
    		</p>

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

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

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/form-anonymous.php

    bbPress will now use this template instead of the original

    Alternately if this all confuses you, I can do this as a plugin, but it would be a paid bit of work (but not expensive) – contact me via http://www.rewweb.co.uk/contact-me/

    #234793
    valarcher
    Participant

    Hi Robin – do you perhaps have any solution to that code? I’m trying to grey out the user’s email on their profile page so they can see it but not be able to update it (same as username). But I need users to update other info like website and bio. That code above does not allow *any* edits to profile page. So my users are unable to write anything into their bio if I use that code.

    #234784
    valarcher
    Participant

    Hi Robin – thanks million for renaming title. That php works perfectly. Sadly the other problem of 1/3-col doesn’t work addressing #bbpress-forums. It works if I target the entire page, then every forum title like this:
    #post-9486,#bbp-forum-9475,#bbp-forum-9473,etc {width:100%;}
    but the moderator doesn’t have access to css so won’t be able to add every forum to css when she creates it.

    I’ll carry on hounding astra for solution. Otherwise worst case scenario I just set blog archives to 1 column.

    While I have you… your code here:
    /** bbPress: add description under forum titles
    https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/ */

    function rw_singleforum_description() {
      echo '<div class="bbp-forumpage-content">';
      echo bbp_forum_content();
      echo '</div>';
    }
    add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');

    You have the first echo as “bbp-forum-content” but by changing it to “forumpage-content”, we’re able to target the description on index page and description on forum page separately in css, eg. on forum pages I have it red bold and centered, whereas on index page I have it in regular left-aligned text.

    Thanks million for all the work you put into the codex! I’m not keen on installing plugins such as your style pack, so codex is really helpful finding just the php I need.

    Do you perhaps have any solution to this code? I’m trying to grey out the user’s email on their profile page so they can’t update it. But I need users to update other info like website and bio. However with code below, if I test writing words in bio (as a logged in participator, not as keymaster) and try saving it, I get “Error: Please enter an email address.” I can see the email greyed out there.

    Do you know a way to fix it so ONLY the email and role can NOT be changed (although role does not even display on a participant user’s page) and everything else can be edited? (except for username of course)

    /** bbPress/WP: prevents subscriber from changing email (greyed out)
    https://www.role-editor.com/hide-disable-wordpress-user-profile-fields/ */

    add_action('admin_init', 'user_profile_fields_disable');
    function user_profile_fields_disable() {
    global $pagenow;
    // apply only to user profile or user edit pages
    if ($pagenow!=='profile.php' && $pagenow!=='user-edit.php') {
    return;
    }
    // do not change anything for the administrator
    if (current_user_can('administrator')) {
    return;
    }
    add_action( 'admin_footer', 'user_profile_fields_disable_js' );
    }
    /**
    * Disables selected fields in WP Admin user profile (profile.php, user-edit.php)
    */
    function user_profile_fields_disable_js() {
    ?>
    <script>
    jQuery(document).ready( function($) {
    var fields_to_disable = ['email', 'role'];
    for(i=0; i<fields_to_disable.length; i++) {
    if ( $('#'+ fields_to_disable[i]).length ) {
    $('#'+ fields_to_disable[i]).attr("disabled", "disabled");
    }
    }
    });
    </script>
    <?php
    }

    I know nothing about php – other than simple stuff like seeing I can change forum-content to forumpage-content!

    #234759
    Robin W
    Moderator

    so for your first, try this

    add_filter( 'get_the_archive_title', 'rew_amend_forums' , 10 , 3) ;
    
    function rew_amend_forums ($title, $original_title, $prefix ) {
    	if ($title == 'Forums') $title = 'Private Forums' ;
    return $title ;
    }

    for your second, this is really one for Astra – I could spend many hours looking for an answer is their code.

    but based on your previous post you could try

    #bbpress-forums {width:100%;}

    #234742
    valarcher
    Participant

    Hi – I’m trying to change the title of my forum index page. I tried item 3 method 2 at:

    Step by step guide to setting up a bbPress forum – Part 1


    — saving my index page as /members (not /forums) as per WP settings, and then tried to give members page in wordpress the title “Private Forums” (instead of title Members). It displays as “Private Forums” (not “Members”) in the breadcrumb. But still on main index page, it displays only the title “Forums.”

    I’m using the shortcode [bbp-forum-index] on /members page as I have text above and below it.

    What can I add to functions.php that will force that index page to display the title “Private Forums”?

    Thank you!

    #234740
    Sergio De Falco
    Participant

    My step up, also install/update Gutenberg standalone plugin to the latest version and add this to your own plugin / theme functions.php

    function envireit_bbp_register_forum_post_type( $args ) {
    	$args['show_in_rest'] = true;
    
    	return $args;
    }
    
    add_filter( 'bbp_register_forum_post_type', 'envireit_bbp_register_forum_post_type' );
    
    function envireit_bbp_register_topic_post_type( $args ) {
    	$args['show_in_rest'] = true;
    
    	return $args;
    }
    
    add_filter( 'bbp_register_topic_post_type', 'envireit_bbp_register_topic_post_type' );
    
    function envireit_bbp_register_reply_post_type( $args ) {
    	$args['show_in_rest'] = true;
    
    	return $args;
    }
    
    add_filter( 'bbp_register_reply_post_type', 'envireit_bbp_register_reply_post_type' );

    With this you will be able to build via site builder, your own forums, topics and replies page. Just replace the content loop with the article content block.

    #234731
    3dbyte
    Participant

    I tested your codes working without problem. By the way I didn’t use header color. Just footer enough because inside “forum index styling” changing already.
    Sincerely thanks Robin, have a good day.

    #234730
    Robin W
    Moderator

    waiting for an email from someone else, so playing with this – this should work

    #bbpress-forums li.bbp-header {
    	background-color: blue;
    }
    #bbpress-forums li.bbp-footer {
    	background-color: green;
    }

    if you put this in

    dashboard>settings>bbp style pack>custom css

    then it will exceute at the right point

    let me know if it doesn’t work

    #234727
    Robin W
    Moderator

    In suspect if you are posting as you (eg say a keymaster) then it won’t do the check, can’t say for sure without delving into code, but try as a participant

    #234722
    Mike Witt
    Participant

    That’s what I was planning to do, but I can’t replicate the problem. When I just make a couple of posts and replies, I don’t get the php notice. That’s why I was thinking maybe it wasn’t bbPress. There must be something special I need to do, to invoke the “blacklist” thing? It happens every once in a while. But I can’t find an action that causes it to happen. I gather that you don’t see it happening, right?

    [10-Mar-2023 04:55:26 UTC] PHP Deprecated: Function get_option was called with an argument that is <strong>deprecated</strong> since version 5.5.0! The "blacklist_keys" option key has been renamed to "disallowed_keys". in .../public_html/wp-includes/functions.php on line 5667

    #234716

    In reply to: Forum Issues

    Robin W
    Moderator
    #234713
    Robin W
    Moderator

    so try this code, amending the numbers to what you want

    if (wp_is_mobile()) {
    add_filter ('bbp_get_topics_per_page', 'mobile_topics_per_page') ;
    add_filter ('bbp_get_replies_per_page', 'mobile_replies_per_page') ;
    }
    
    function mobile_topics_per_page () {
    	return '4' ;
    }
    
    function mobile_replies_per_page () {
    	return '3' ;
    }

    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

    #234694

    In reply to: MySQL Syntax Error

    Robin W
    Moderator

    ok, not quite sure why this occurred, but the bit that says

    ('4185', 'as__bbp_favorites, '312810')

    is lacking a closing ‘ on 'as__bbp_favorites so should read

    ('4185', 'as__bbp_favorites', '312810')

    Is this a one off, or is it now doing this everytime?

    #234692
    paulmist
    Participant

    This works great with a minor tweak…

    if( !is_user_logged_in() && $rep_position > 1 )

    However – is it possible to hide replies and not just their content?

    Tried using bbp_get_reply as a filter with no luck.

    #234685
    ljmac
    Participant

    Hi,

    A MySQL syntax error has started cropping up recently, even though I have made no changes that might be related to this (same MySQL version, same PHP version, same bbPress version, same WordPress version). Can anyone enlighten me on what might be causing this?

    Once again, this only started happening recently despite the lack of any significant related changes – I have been doing forum repairs for years without any errors.

    [09-Mar-2023 05:01:55 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘312810’)’ at line 2 for query INSERT INTO as_usermeta (user_id, meta_key, meta_value) VALUES
    (‘4185’, ‘as__bbp_favorites, ‘312810’); made by require_once(‘wp-admin/admin.php’), do_action(‘load-tools_page_bbp-repair’), call_user_func_array, bbp_admin_repair_handler, call_user_func, bbp_admin_repair_user_favorites

    #234680
    wpturk
    Participant

    This should do the job: (put this in your functions.php)

    function bb_auth_reply_view( $reply_id ) {
            $reply_id = bbp_get_reply_id( $reply_id );
    
            // Check if password is required
            if ( post_password_required( $reply_id ) )
            return get_the_password_form();
    
            $content = get_post_field( 'post_content', $reply_id );
    
            // first topic reply shouldn’t be hiding
            $rep_position = bbp_get_reply_position($reply_id);
    
            // if user is not logged in and not the first post topic
            if( !is_user_logged_in() ) {
                    return "Replies only viewable for logged in users";
            } else {
                    // return normal
                    return $content;
            }
    
    }
    add_filter( 'bbp_get_reply_content', 'bb_auth_reply_view' );
Viewing 25 results - 651 through 675 (of 32,358 total)
Skip to toolbar