Forum Replies Created
-
In reply to: Restrict links only for registered users.
You can use
bbp_get_reply_content
filter, but this can be a disaster when you take off all the links that other plugins or the theme could have in the reply content. A good example is the mentions being added by BuddyPress, but after using this, they turn into the restriction notice..add_filter('bbp_get_reply_content', 'restricted_links', 20, 2); function restricted_links($content, $post_id) { if ( is_user_logged_in() ) return $content; return preg_replace_callback( '/<a(.*?)href(.*?)>(.*?)<\/a>/si', function($m){ return sprintf( '<span class="protected-link" style="background:#f3f3f3;padding: 2px 5px;display:inline-block;border-radius:3px">[Restricted Link] Please <a href="%s">register</a> to view this link</span>', home_url('/wp-login.php?action=register') ); }, $content ); }
You may pass-in the link text after the notice or something, it is all up to you so play around with the code or ping me if you needed help.
In reply to: Private messaging system for bbpress and wordpressHello,
Sorry if I am bumping this old thread, but there’s already a thread open for this over wporg support forums at https://wordpress.org/support/topic/does-this-have-shortcode-can-use-this-in-wordpress-sidebar-as-form/. I left you a reply from there.
Best,
SamuelIn reply to: bbp-messagesHello everyone,
Sorry but I just came to discover this thread, I am the author of bbp-messages and there’s now a major update made and it now supports Multisite, the problem that Stewart was reporting.
Also Stewart, the link
wordpress/members1/http:/localhost/wordpress/members1/
pretty much seems messed up, so it’s hard to tell whether it is bbP issue or configuration. I think you did not configure your testing environment quite well and also the bbPress link looks filtered by BuddyPress. Next time I’d suggest you edit your hosts file (c:\System32\drivers\etc\hosts
with admin permissions using notepad) and add a new entry127.0.0.1 bbpress.dev
nowbbpress.dev
will act like a normal domain and you wouldn’t run into issues while testing or migrating (all you can do is replace.dev
with.tld
in the db SQL file). Also add the virtual host for Apache http://stackoverflow.com/a/25203499/3910932Thank you Arutam and Robin you’re very helpful. I just wanted to point that this thread continues in wp-org plugin support forums https://wordpress.org/support/topic/messages-upgrade/
Best,
SamuelIn reply to: Create new forum topic from a WP post?You’re welcome all. Happy to be able to help 🙂
@wasanajones You can useget_the_excerpt( $se_post )
or justpost_excerpt
property of theWP_Post
object:Edit the last callback from previous code to go as this:
add_filter('bbp_get_form_topic_content', function( $body ) { global $se_post; if( $se_post ) { return $se_post->post_excerpt; } return $body; });
I did not test this but I am sure it should work.
Best,
SamuelHi contemplate,
Can you make a skimmed down version of your solution for people who have ONLY bbpress?
/** * Hooked into the new reply function, this notification action is responsible * for notifying topic and hierarchical reply authors of topic replies. * Fixed: https://bbpress.org/forums/topic/new-reply-notification-link-to-the-reply/ */ function bbp_buddypress_add_notification_custom( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0 ) { // Bail if somehow this is hooked to an edit action if ( !empty( $is_edit ) ) { return; } // Get autohr information $topic_author_id = bbp_get_topic_author_id( $topic_id ); $secondary_item_id = $author_id; // Hierarchical replies if ( !empty( $reply_to ) ) { $reply_to_item_id = bbp_get_topic_author_id( $reply_to ); } // Get some reply information $args = array( 'user_id' => $topic_author_id, 'item_id' => $reply_id, 'component_name' => bbp_get_component_name(), 'component_action' => 'bbp_new_reply', 'date_notified' => get_post( $reply_id )->post_date, ); // Notify the topic author if not the current reply author if ( $author_id !== $topic_author_id ) { $args['secondary_item_id'] = $secondary_item_id ; bp_notifications_add_notification( $args ); } // Notify the immediate reply author if not the current reply author if ( !empty( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) { $args['secondary_item_id'] = $reply_to_item_id ; bp_notifications_add_notification( $args ); } } remove_action( 'bbp_new_reply', 'bbp_buddypress_add_notification', 10 ); add_action( 'bbp_new_reply', 'bbp_buddypress_add_notification_custom', 10, 7 );
In reply to: mentions not becoming links some timesCan you point me to the function that converts @mentions to links. I feel like I can figure this out but I can’t find where it’s being converted.
It is called
bbp_make_mentions_clickable
and locatedline:424
of\includes\common\formatting.php
. The function is hooked in\includes\core\filters.php:248
In reply to: Content warning if posts contain certain wordsThank you Pascal 🙂 !!
angelis, you’re welcome. I’ll put this into a plugin and link you to the Github repository shortly.
@kieranw7261 my best guess is you’re running an EOL PHP version which is less than the recommended (see https://wordpress.org/about/requirements/)No worries just try this instead http://pastebin.com/XBeKjRFF and let me know if it worked.
Samuel
In reply to: Content warning if posts contain certain wordsHello,
I have made this a little simple, where any visitor can have an overlay division hiding the topic content and everything when there are caught words in the currently viewing topic..
You can add this code to your theme’s functions file:
Remember: edit
$list = 'test,bad topic,';
line to insert your watched words separated by commas without a space after the commas.add_action('wp', function() { /** * Add the watched words or sentences separated by commas. * Remember not to add a space before the words * Example : 'evil dog,naughty cat,pig' */ $list = 'test,bad topic,'; // set up a global variable for our case $GLOBALS['my_filtered_words'] = explode(',', $list); }); add_action('bbp_theme_after_reply_content', function() { if( ! get_the_ID() ) return; $topic = get_post( get_the_ID() ); if( ! $topic || 'topic' !== $topic->post_type ) return; global $my_filtered_words; $words = preg_split( "/\s+/", $topic->post_content ); foreach( $words as $i => $word ) $words[$i] = strtolower($word); $occurance = 0; foreach( $my_filtered_words as $string ) { $string = strtolower( $string ); $occurance += in_array( $string, $words ) ? 1 : 0; } if( ! ( $occurance > 0 ) ) return; // nothing caught $cookie = isset( $_COOKIE['se_conf_warned_topics'] ) ? explode(',', $_COOKIE['se_conf_warned_topics']) : array(); if( in_array($topic->ID, $cookie) ) return; // confirmed before. ?> <style type="text/css"> .se-conf-wt {position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.78); width: 100%; height: 100%; z-index: 999;} .se-conf-wt p {color: #fff; position: relative; top: 50%; display: table;margin: 0 auto;} .se-conf-wt a {color:#fff;} </style> <div class="se-conf-wt t-<?php echo $topic->ID; ?>"> <p>This topic contains offensive content. <a href="javascript:;">Continue?</a></p> </div> <script type="text/javascript"> window.onload = function() { var a = document.querySelector('.se-conf-wt.t-<?php echo $topic->ID; ?> a'), b = document.body; a.onclick = function() { var expires = new Date(), cval = '<?php echo isset($_COOKIE['se_conf_warned_topics']) ? $_COOKIE['se_conf_warned_topics'] : ''; ?>'; expires.setMonth(expires.getMonth() + 6); // 6 months expiracy date cval += '<?php echo $topic->ID; ?>,'; document.cookie = "se_conf_warned_topics=" + cval + "; expires=" + expires; // cookie set, now let's hide the warning this.parentNode.parentNode.remove(); b.style.overflowY = ''; return false; } b.style.overflowY = 'hidden'; } </script> <?php });
Tested on my local installation and it works fine.
Let me know how it goes.Samuel
In reply to: Create new forum topic from a WP post?Hello, here are the steps for you:
1. Create a ‘new topic’ page at example.com/new-topic/ and add
[bbp-topic-form]
shortcode as content.
2. Add this code to your child theme’s functions file:add_filter('the_content', function($content) { global $post; if( 'post' == $post->post_type && is_user_logged_in() ) { $content .= '<p><a href="' . home_url('new-topic/?se_pid=' . $post->ID) . '">Generate a topic</a></p>'; } return $content; }); add_action('init', function() { $content = null; if( isset( $_GET['se_pid'] ) ) { $pid = (int) $_GET['se_pid']; $content = get_post( $pid ); } $GLOBALS['se_post'] = $content; }); add_filter('bbp_get_form_topic_title', function( $title ) { global $se_post; if( $se_post ) { return $se_post->post_title; } return $title; }); add_filter('bbp_get_form_topic_content', function( $body ) { global $se_post; if( $se_post ) { return $se_post->post_content; } return $body; });
Test it out, go to your posts and scroll down to the bottom, click the “generate ..” link and see if it worked.
I am here for any further customization or if you encounter issues with implementing this.
Regars,
SamuelIn reply to: Edit the bbPress login widgetI wanted to do that too.. but unfortunately I couldn’t find a better answer so I had to edit the widgets file under includes/common/widgets.php ( my forum ) .
In reply to: Allow HTML from usersAs of ~2.3, the “allowed tags” are filterable within bbPress.
Look for the filter bbp_kses_allowed_tags. It’s in includes/common/formatting.php.
@jaredatch , thank you so much man!! been able to allow some extra tags.. and been looking for this long time ago, until i gave up -(
appreciated 😀show only a the login widget and it will turn to user profile name and avatar after logged in, once logged out it shows again login form with register link below it.. is that what u want?
In reply to: where to edit topics page template ?bbpress/includes/topics/template.php
In reply to: remove rel=nofollow from bbpress poststhank you so much Gautam it worked for me .
bbpress/includes/core/filters.php
: added :add_filter( 'bbp_get_reply_content', 'bbp_rel_nofollow' ); add_filter( 'bbp_get_topic_content', 'bbp_rel_nofollow' );