Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 626 through 650 (of 32,358 total)
  • Author
    Search Results
  • #235163

    In reply to: Formatted text

    wpturk
    Participant

    Hi, mostly formatting comes with copy-paste of html text. If you want to strip html from the text you can make use of some WordPress functions: wp_strip_all_tags(), convert_chars() etc …

    ex:

    function aa_stripped_content($content) {
        
        $content = wp_strip_all_tags($content);
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'aa_stripped_content'); 
    #235139
    Robin W
    Moderator

    ok, so if you go to

    dashboard>subjects>all subjects, and then select ‘les abonnements’ (the subscriptions) for the chosen subject then select option ‘subscribe selected users’ and apply

    are they then showing as ‘sucbribed’ and this in not working, or does the subssribed/unsubscribed not change ?

    #235131
    enkoes
    Participant

    Brilliant! Thanks for the codes. Just tested and it works like a charm! 😀

    #235129
    wpturk
    Participant

    As I guessed, it’s coming from your theme

    You can try this: (it’s not tested)

    function aa_profile_title ( $title, $id ) {
    
            if ( bbp_is_single_user_profile() && empty(get_post_type($id)) ) {
    
                    $author_id = bbp_get_displayed_user_field('ID');
                    $nickname = um_get_display_name( $author_id );
                    $title = $nickname;
            }
            return $title;
    }       
    add_filter( 'the_title', 'aa_profile_title', 10, 2);
    #235126

    In reply to: Related topics!

    imFiles
    Participant

    This one works for bbpress: https://wordpress.org/plugins/contextual-related-posts/ if you want only related topics just go into Contextual Related Posts Settings and on the List tuning tab and on Post types to include select topic only. One thing it doesn’t have an automatic option to add the related items, so you need to added them either manually or the best way is with a fucntion.
    I use this one to add it after each topic:

    //add adsense after topic
    add_action( 'bbp_template_after_replies_loop', 'rew_other_topics' );
    function rew_other_topics () {
    	 $topic_id = bbp_get_topic_id() ;
    	 $forum_id = bbp_get_topic_forum_id($topic_id) ;
    	if ( function_exists( 'echo_crp' ) ) { echo_crp(); }
    }
    #235120
    wpturk
    Participant

    you have to be careful with the Quotation marks, try:

    $before ='<p style="text-align:center">TEXT BEFORE</p>';

    #235118
    enkoes
    Participant

    Hi, I would like to display nickname (and not username) in the whole bbpress forum.

    For topics list, I modified the code from a previous topic Show username instead of full name / display name and it works well so far.

    See https://paste.pics/MVA62

    The modified codes that I use is as follows:

    add_filter( 'bbp_get_reply_author_display_name' , 'rew_reply_change_to_nickname', 10 , 2 ) ;
    
    function rew_reply_change_to_nickname ($author_name, $reply_id) {
    	// Get the author ID
    	$author_id = bbp_get_reply_author_id( $reply_id );
    	$nickname = um_get_display_name( $author_id );
    return $nickname ;
    }
    
    add_filter( 'bbp_get_topic_author_display_name' , 'rew_topic_change_to_nickname', 10 , 2 ) ;
    
    function rew_topic_change_to_nickname ($author_name, $topic_id) {
    	// Get the author ID
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$nickname = um_get_display_name( $author_id );
    return $nickname ;
    }

    Note: I use Ultimate Member (UM) plugin to display user details.

    However, when comes to user profile, I’m struggling on how to force display nickname right above the avatar. Hope you can help me with that.

    See https://paste.pics/MVA6A

    Note: It’s very tedious to modify “display name publicly as” from the WordPress dashboard for every registered user. Thus hopefully codes may well do the job for me.

    #235111
    wpturk
    Participant

    Here we go:

    function add_custom_content($content) {
    
        $topic_id = bbp_get_topic_id();
        $user_id = bbp_get_topic_author_id( $topic_id );
    
        if ( bbp_is_user_keymaster($user_id) ) {
    
                $before ="<p>TEXT BEFORE</p>";
                $after ="<p>TEXT AFTER</p>";
                $content = $before . $content . $after;
        }
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content');
    #235108

    In reply to: Related topics!

    wpturk
    Participant

    I’ve played with this today.

    If you are using tags in your topics, this will print the 5 related topics based on tags.
    (You need to put this in your functions.php)

    function aa_related_topics() {
    
            $topic_id = bbp_get_topic_id();
            $tags = wp_get_post_terms( $topic_id, bbp_get_topic_tag_tax_id(), array( 'fields' => 'ids' ) );
    
            $args = array(
                    'post__not_in' => array($topic_id),
                    'post_type'  => bbp_get_topic_post_type(),
                    'posts_per_page' => 5,
                    'orderby'   => 'rand',
                    'tax_query' => array(
                            array(
                                    'taxonomy' => bbp_get_topic_tag_tax_id(),
                                    'terms'    => $tags,
                            ),
                    ),
            );
    
            $my_query = new wp_query( $args );
    
            if( $my_query->have_posts() ) {
                echo '<div id="related"><h4>Related Posts</h4>';
                    while( $my_query->have_posts() ) {
                        $my_query->the_post(); ?>
                        <div>
    
                            <h5><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
    
                        </div>
                    <?php }
                    wp_reset_postdata();
                echo '</div>';
            }
    
    }
    add_action( 'bbp_template_after_single_topic', 'aa_related_topics' ); 
    #235105
    wpturk
    Participant

    This would do the job. Put this in your functions.php and replace the text.

    function add_custom_content($content) {
        
        $before ="<p>TEXT BEFORE</p>";
        $after ="<p>TEXT AFTER</p>";
        $content = $before . $content . $after;
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content'); 
    #235103
    Robin W
    Moderator

    yes the issue was fixed by Astra in 4.1.2 after I raised it with them.

    I just looked and there was an interim version they released which didn’t have the fix, but which my code did not pick up on, so that was the one you were on – apologies, I should have thought of that, but it was only live for a very short period.

    Anyway glad you are fixed.

    #235102
    rtgrdh
    Participant

    Running Atra 4.1.2. I had the issue with Bbpress forum search gets stuck using Astra theme.

    I came across your code in another thread and implemented it into functions.php and the issue stopped, although I wanted to use the plugin instead.

    I was actually running the non-latest version of Astra, and it seems like the issue resolved itself after updating the theme to 4.1.2.

    #235090
    Robin W
    Moderator

    hmmm.. that meta_key is used during transition, but should I think be deleted as part of the cleanup process. It is not needed in normal use.

    There is some code called during password process that does a check which is where this is falling down

    I’d suspect that then process did not complete correctly and has left this behind.

    I’d suggest a couple of actions.

    Firstly find a user who can help you, who has not changed password and who can log on. Without them (or you!) changing their password, delete the ‘_bbp_class’ meta key, and check that they can still log in ok. If so, then get them to change password and check that all is ok.
    That should then give you confidence that this key is not needed for some interim process.

    Then

    1. if you have the knowledge to backup the user table so that you have a record, I’d suggest you take a copy and then run some php/sql to delete these records
    2. more cautiously, I’d suggest maybe you rename that meta-key, that way you can name it back if needbe.

    both of these would require pho or sql knowledge.

    I’m quite happy to help if you’d like – contact me via http://www.rewweb.co.uk/contact-me/ with a link to this thread so I can tie it up.

    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.

Viewing 25 results - 626 through 650 (of 32,358 total)
Skip to toolbar