Search Results for 'code'
-
AuthorSearch Results
-
April 11, 2023 at 1:03 am #235294
In reply to: Close topic label
enkoesParticipantHi, do u mean we replace
add_filter ('the_title' , 'rew_add_close_to_topics') ;
with
add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);
?April 10, 2023 at 10:08 am #235289In reply to: Close topic label
wpturkParticipantYou can use
add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);
April 9, 2023 at 6:53 am #235241In reply to: Close topic label
Robin WModeratorI’ll add this functionality to style pack in a few days, but in the meantime
add_filter ('the_title' , 'rew_add_close_to_topics') ; function rew_add_close_to_topics ($title) { if ( bbp_is_topic_closed()) { $closed = '[Closed]' ; $sep = ' ' ; $position = 'after' ; if (($position == 'before') && !str_contains($title, $closed)) $title = $closed.$sep.$title ; if (($position =='after') && !str_contains($title, $closed)) $title = $title.$sep.$closed ; } return $title ; }
and amend words/position etc. as you wish.
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
and change the background of the closed block to match your theme
April 9, 2023 at 5:53 am #235238In reply to: Customizing lead topic
Robin WModeratorso is this with this function installed?
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 ; }
April 8, 2023 at 3:19 pm #235229In reply to: Adding a line of text above/below each topic
wpturkParticipantProbably, your theme or one of your plugin is already modifying external links to add “nofollow” attributes etc … and simultaneously breaking
target="_blank"
… Difficult to say before checking your theme and all your plugins. I would removetarget="_blank"
if it’s not working.April 8, 2023 at 6:51 am #235223In reply to: Adding a line of text above/below each topic
wpturkParticipant🙂
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) ) { $after ='<p><i>Still struggling with your website(s) speed? Click <strong><a href="https://example.com/" target="_blank">here</a></strong>.</i></p>'; $content = $content . $after; } return $content; } add_filter ('bbp_get_topic_content', 'add_custom_content');
April 8, 2023 at 4:50 am #235221In reply to: Adding a line of text above/below each topic
wpturkParticipantyou have to be careful with the quotation marks:
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) ) { $after ='<p><i>Still struggling with your website(s) speed? Click <a href="https://example.com/">here</a>.</i></p>'; $content = $content . $after; } return $content; } add_filter ('bbp_get_topic_content', 'add_custom_content');
April 7, 2023 at 5:46 am #235208In reply to: Adding a line of text above/below each topic
wpturkParticipantYou can change the $before and $after variables to whatever you like. For example an external link before all topics:
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>This is my <a href="https://bbpress.org/">EXTERNAL LINK</a>.</p>'; $after ='<p>TEXT AFTER</p>'; $content = $before . $content . $after; } return $content; } add_filter ('bbp_get_topic_content', 'add_custom_content');
For the excerpt issue you can give a try with another priority:
function filter_the_excerpt( ) { return ' '; } add_filter( 'the_excerpt', 'filter_the_excerpt', 999, 2 );
April 7, 2023 at 2:57 am #235189In reply to: Adding a line of text above/below each topic
Philippe RousselParticipantNo, that doesn’t do anything. I asked the question to the plugin author a few days ago but got no answer. One last request regarding the code you gave me earlier on: How can I insert an external link in my [TEXT]?
April 6, 2023 at 4:25 pm #235182In reply to: Adding a line of text above/below each topic
wpturkParticipantHi, I’ve not used this plugin so I don’t know how it works.
Maybe the plugin is using the WordPress excerpt, you can try this:
add_filter( 'the_excerpt', 'filter_the_excerpt', 10, 2 ); function filter_the_excerpt( ) { return ' '; }
April 6, 2023 at 10:58 am #235177In reply to: Adding a line of text above/below each topic
Philippe RousselParticipantHi,
I use the Post Comments as bbPress Topics plugin, which gives by default an excerpt of the concerned post. None of the other options seem to work but none of them suit me either. Expanding on the php code you gave earlier in this thread, would it be possible to simply delete all content in the topic other than “[See the full post at: …]” and, of course, my own [TEXT]?
Thank you
April 6, 2023 at 4:18 am #235166In reply to: Formatted text
wpturkParticipantyou need this additional line if you want to strip replies too:
add_filter ('bbp_get_reply_content', 'aa_stripped_content');
April 5, 2023 at 11:17 am #235163In reply to: Formatted text
wpturkParticipantHi, 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');
April 3, 2023 at 12:35 pm #235139In reply to: BBpress forum subscription default setting
Robin WModeratorok, 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 ?
April 3, 2023 at 1:57 am #235131In reply to: Show nickname instead of username
enkoesParticipantBrilliant! Thanks for the codes. Just tested and it works like a charm! 😀
April 3, 2023 at 12:24 am #235129In reply to: Show nickname instead of username
wpturkParticipantAs 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);
April 2, 2023 at 7:58 pm #235126In reply to: Related topics!
imFilesParticipantThis 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(); } }
April 2, 2023 at 10:07 am #235120In reply to: Adding a line of text above/below each topic
wpturkParticipantyou have to be careful with the Quotation marks, try:
$before ='<p style="text-align:center">TEXT BEFORE</p>';
April 1, 2023 at 6:34 pm #235118Topic: Show nickname instead of username
in forum TroubleshootingenkoesParticipantHi, 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.
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.
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.
April 1, 2023 at 5:03 am #235111In reply to: Adding a line of text above/below each topic
wpturkParticipantHere 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');
March 31, 2023 at 10:14 pm #235108In reply to: Related topics!
wpturkParticipantI’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' );
March 31, 2023 at 2:03 pm #235105In reply to: Adding a line of text above/below each topic
wpturkParticipantThis 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');
March 31, 2023 at 9:26 am #235103In reply to: Blank topic pages while using TwentyTwentyTwo theme.
Robin WModeratoryes 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.
March 31, 2023 at 9:15 am #235102In reply to: Blank topic pages while using TwentyTwentyTwo theme.
rtgrdhParticipantRunning 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.
March 30, 2023 at 4:17 pm #235090In reply to: Login errors after conversion form PHPBB
Robin WModeratorhmmm.. 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.
-
AuthorSearch Results