Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 576 through 600 (of 32,295 total)
  • Author
    Search Results
  • norcom41
    Participant

    I considered how tricky it might be to customize how forum functioning takes place. I read that you can create new roles that redefine what capabilities users have even to do things differently. But roles don’t seem to be stored in wp_users. However I did read that definitions are in the wp_users_roles option of the wp_options table. There are forum roles which would have to be coded differently using hooks, filters and actions. It’s always best to keep things simple. It sounds so complex that maybe it would be better to tell students not to create new topics or else the administrator would just have to delete them.

    #235036

    In reply to: Customizing lead topic

    Robin W
    Moderator

    you can leave the template for time unchanged.

    add_filter ('bbp_get_topic_post_date' , 'rew_change_to_freshness', 10 , 6) ;
    add_filter ('bbp_get_reply_post_date' , 'rew_change_to_freshness', 10 , 6) ;
    
    function rew_change_to_freshness ($result, $topic_id, $humanize, $gmt, $date, $time) {
    	$result = bbp_get_time_since( bbp_convert_date( $time ) ) ;
    	
    return $result ;
    }

    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

    #235034

    In reply to: Customizing lead topic

    enkoes
    Participant

    Yes, found it. I have deleted the header & footer part in the php file and put in my child theme.

    Does the date function look like this below?
    <span class="bbp-topic-post-date"><?php bbp_topic_post_date(); ?></span>

    May I know what is the freshness function so that I can replace it with?
    Other than lead topic, how about other replies? I want them to display freshness as well.

    Regards with thanks!

    Robin W
    Moderator

    private groups will do what you want.

    Basically you have a choice.

    1. develop code yourself
    2. use code someone else has written
    3. pay someone to write code for you
    4. use a plugin and set this up yourself
    5. use a plugin and pay someone to set it up for you.

    My private groups plugin does what you need – I do not write separate plugins for every circumstance, everyone wants something slightly different ๐Ÿ™‚

    Anyway I’ll let you consider. Quite happy to do option 5 if you want some help

    norcom41
    Participant

    In Oct/2022 I found http://www.buddydev.com/restrict-user-from-creating-topic-on-certain-bbpress-forums. I printed out some code to look at it and some comments about it. I put the info in the learn how to use short-code in my notebook to study when I had time. It seemed complicated and only for advanced developers and I haven’t used short-codes as yet. But most of the developer reviews in that place seemed positive. The few negatives had to do with the code being beyond their expertise. I checked the reference in your reply and it seemed to fall into the category of an advanced approach. But I was just wondering if someone by now had figured out an easier way to solve my question because it seems to be a logical requirement to have a solution for. However, in my searching one person said “who would want to do something like that when that’s not what it’s meant for” I’ll have to study it all so I can be more comfortable trying it.

    #235009
    enkoes
    Participant

    Hi, I’m using the codes below to show lead topic:

    function custom_bbp_show_lead_topic( $show_lead ) {
      $show_lead[] = 'true';
      return $show_lead;
    }
     
    add_filter('bbp_show_lead_topic', 'custom_bbp_show_lead_topic' );

    As shown in the screenshot below,

    https://paste.pics/MQEKW

    My questions are:
    a. Can I hide the header & footer (item 1) right above and below the lead topic?
    b. Can I change the date display (item 2) to freshness display (e.g., 2 weeks, 5 days ago) for all topics/replies?

    Regards.

    #234977
    sirhc
    Participant

    I have spent all morning and early afternoon trying to sort something out from bbpress! I am almost giving up.

    When I search something in the forum index, it messes completely the appearance of the site. The custom footer and header from DIVI which is applied to all pages is not used. The menu is a mess, with my logo having its original size, menu appearing vertically including subitems….

    I tried just having the shortcode for the search in a separate page, but again the same.

    Search
    [bbp-search] โ€“ Display the search input form.
    [bbp-search-form] โ€“ Display the search form template.

    Anyone can help??

    #234956

    In reply to: SEO friendly theme

    Robin W
    Moderator

    try adding this to your theme’s custom css

    @media only screen and (max-width: 480px) {
    
    #bbpress-forums .bbp-body div.bbp-reply-author, #bbpress-forums .bbp-body div.bbp-topic-author {
    	float: none;
    	margin: 0px; 
    	min-height: 2px;
    }
    
    }
    #234952

    In reply to: SEO friendly theme

    Robin W
    Moderator

    This code will truncate the title

    add_filter ('bbp_new_topic_pre_title' , 'rew_limit_topic_length' ) ;
    add_filter ('bbp_edit_topic_pre_title' , 'rew_limit_topic_length' ) ;
    
    function rew_limit_topic_length  ($topic_title) {
    	$length = 40 ;
    	if (strlen($topic_title) > $length) {
    		$topic_title = substr($topic_title, 0, $length);
    	}
    return $topic_title ;
    }

    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

    for your second issue, it is site/theme specific, I’d need to see the site and a real example

    #234901
    wblank83
    Participant

    Howdy y’all,

    Trying to create a bbpress forum with the Winkel theme

    I put the index short code on my page, but when I click through the forum link, I get a blank page

    It isn’t plugin related, and I’ve already tried downloading Robin Wilson’s bbp style pack plugin to no avail

    Does anyone have some insight into this? I’ve seen it posted several times but just can’t get this to work.

    #234847
    rinh
    Participant

    That’s an interesting plugin. But agree gutenberg gets a little convoluted when only used as a text editor.

    What I had in mind was being able to add some of the bbPress widgets to the page having the forum root shortcode. These widgets doesn’t seem to appear in gutenberg.

    bbPress widgets

    #234845
    rinh
    Participant

    It would be good indeed, FSE looks like the future of WordPress.

    I just started so I don’t know much, and I think I’ll be in forever learning ๐Ÿ˜‰ I think a template part that is the forum would work best though, but I could be completely wrong on that. I can type down what I’ve got so far though.

    From what I’ve gathered so far (I could be wrong on some things here). There are several kinds of templates, for example Archive and Single. Single displays the layout for single posts and that seem to be what all pages except forum root are.

    Simply put the templates work in that way you build a layout using the block editor where you can put in single post parts like post title, post content and so on. In Elementor I made a Single with just post content and magically the post content would display the forum on the front-end.

    bbPress forum root appear to be an archive, but since it has a shortcode forum root wouldn’t need anything more I think.

    The FSE recognise custom post types and you can make Single templates for those. I’m not sure if bbPress is a custom post type, but if it is and FSE would recognise it that would’ve solved it all.

    Hope that makes any sense.

    #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%;}

Viewing 25 results - 576 through 600 (of 32,295 total)
Skip to toolbar