Search Results for 'code'
-
AuthorSearch Results
-
March 4, 2019 at 7:10 am #199037
In reply to: Comments Blacklist
Robin W
Moderatorok, try this plugin
once activated go to tools>bbp blacklist checker
This lets you switch off the code that is causing the issue.
It’s just a bit of testing code, not intended for permanent live use, but may help confirm if it’s bbpress or something behind that is causing the issue.
Try it for both anew post and an edited one
March 3, 2019 at 4:06 pm #199003In reply to: Layout for Categories
pixelzen
ParticipantYes I got that far, not sure how to use modify the following code just for that sepecific category/forum This is the code for the discussion page
<?php
/**
* [g1_bbp_forums] shortcode callback function.
*
* @param array $atts
* @param string $content
* @return string
*/
function g1_bbp_forums_shortcode( $atts, $content ) {
/* We need a static counter to trace a shortcode without the id attribute */
static $counter = 0;
$counter++;
extract( shortcode_atts( array(
‘id’ => ”,
‘class’ => ”
), $atts, ‘g1_bbp_forums’ ) );
// Compose final HTML id attribute
$final_id = strlen( $id ) ? $id : ‘g1-bbp-forums-‘ . $counter;
// Compose final HTML class attribute
$final_class = array(
‘g1-bbp-forums’,
);
$final_class = array_merge( $final_class, explode( ‘ ‘, $class ) );
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_normalize_forum_visibility action and function.
$query = new WP_Query( array(
‘post_type’ => bbp_get_forum_post_type(),
‘post_parent’ => $settings[‘parent_forum’],
‘post_status’ => bbp_get_public_status_id(),
‘posts_per_page’ => get_option( ‘_bbp_forums_per_page’, 50 ),
‘ignore_sticky_posts’ => true,
‘no_found_rows’ => true,
‘orderby’ => ‘menu_order title’,
‘order’ => ‘ASC’
) );
if ( ! $query->have_posts() ) {
return ”;
}
// Start output buffer
ob_start();
?>
<div class=”<?php echo implode( ‘ ‘, array_map( ‘sanitize_html_class’, $final_class ) ); ?>”>
<div class=”g1-collection g1-collection–grid g1-collection–one-third g1-collection–simple”>-
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<li class=”g1-collection__item”>
<article>
<?php if ( has_post_thumbnail() ): ?>
<figure class=”entry-featured-media”>post->ID ); ?>”>
<?php the_post_thumbnail( ‘g1_one_third’ ); ?>
</figure>
<?php else: ?>
<?php echo do_shortcode( ‘[placeholder icon=”camera” size=”g1_one_third”]’ ); ?>
<?php endif; ?>
<div class=”g1-nonmedia”>
<div class=”g1-inner”>
<header class=”entry-header”>
<h3 class=”entry-title”>
post->ID ); ?>”><?php bbp_forum_title( $query->post->ID ); ?>
</h3>
<p class=”entry-meta g1-meta”>
<span><?php _e( ‘Topics’, ‘bbpress’ ); ?>: <?php bbp_forum_topic_count( $query->post->ID ); ?></span>
<span><?php bbp_show_lead_topic() ? _e( ‘Replies’, ‘bbpress’ ) : _e( ‘Posts’, ‘bbpress’ ); ?>: <?php bbp_show_lead_topic() ? bbp_forum_reply_count( $query->post->ID ) : bbp_forum_post_count( $query->post->ID ); ?></span>
</p>
</header>
<div class=”entry-summary”>
<?php the_excerpt(); ?>
</div>
</div>
</div>
</article><?php endwhile; ?>
</div>
</div>
<?php
// Reset the $post global
wp_reset_postdata();
// Return and flush the output buffer
return ob_get_clean();
}
add_shortcode( ‘g1_bbp_forums’, ‘g1_bbp_forums_shortcode’ );March 3, 2019 at 12:23 pm #198995In reply to: Allow Participants to Trash / own Topics and Posts
Robin W
Moderatorfor anyone finding this topic
I kicked this code around to improve it and also stop the 404 error when a participant trashes a topic, so latest version is
/*Customize the BBPress roles to allow Participants to trash topics*/ add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 ); function ST_add_role_caps_filter( $caps, $role ){ // Only filter for roles we are interested in! if( $role == bbp_get_participant_role() ) { //only change delete topics $caps ['delete_topics']= true ; } return $caps; } /*then only allow participants to trash their own topics*/ add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){ // apply only to delete_topic if ( $cap == "delete_topic" ){ // Get the post $_post = get_post( $args[0] ); if ( !empty( $_post ) ) { // Get caps for post type object $post_type = get_post_type_object( $_post->post_type ); // Add 'do_not_allow' cap if user is spam or deleted if ( bbp_is_user_inactive( $user_id ) ) { $caps[] = 'do_not_allow'; // Moderators can always edit forum content } elseif ( user_can( $user_id, 'moderate' ) ) { $caps[] = 'moderate'; // User is author so allow edit if not in admin } elseif ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) { $caps = array(); // Unknown so do not allow } else { $caps[] = 'do_not_allow'; } } } // return the capabilities return $caps; } //then redirect to the forum after trashing topic add_action('bbp_template_redirect', 'ST_trash_topic_check', 8); //check if topic has been trashed by author and show forum if it has function ST_trash_topic_check() { $topic_slug = get_option( '_bbp_topic_slug') ; //quick check if we need to do this function, so bail if not a topic if (strpos($_SERVER['REQUEST_URI'], $topic_slug) == FALSE) return ; $forum_slug = bbp_get_root_slug() ; //if check is set (ie we prefix forums with the forum slug) then part 1 will be forum slug and part 2 will be topic slug, if not part 1 will be topic slug $check = bbp_include_root_slug() ; $link = explode('/',$_SERVER['REQUEST_URI']); //next we need the topic id (post id) of the topic so we need to check if it is a topic and if so, find the topic id if (is_user_logged_in() && $check && $link[1] == $forum_slug && $link[2] == $topic_slug ) { $post = bsp_get_page_by_slug( $link[3], OBJECT, 'topic' ); $login_check=1 ; } elseif (is_user_logged_in() && empty($check) && $link[1] === $topic_slug) { $post = bsp_get_page_by_slug( $link[2], OBJECT, 'topic' ); $login_check=1 ; } //now we need to check if the topic has been trashed by author if (!empty ($login_check) && $post->post_status == 'trash' && $post->post_author == get_current_user_id() ) { $topic_id = $post->ID; //then redirect to the forum we came from $forum = bbp_get_forum_permalink (bbp_get_topic_forum_id ( $topic_id )) ; wp_redirect ($forum) ; exit ; } else return ; }I’ll add this function into my style pack plugin shortly
March 3, 2019 at 12:21 pm #198994In reply to: How to let Authors delete their own posts?
Robin W
ModeratorI kicked this code around to improve it and also stop the 404 error when a participant trashes a topic, so latest version is
/*Customize the BBPress roles to allow Participants to trash topics*/ add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 ); function ST_add_role_caps_filter( $caps, $role ){ // Only filter for roles we are interested in! if( $role == bbp_get_participant_role() ) { //only change delete topics $caps ['delete_topics']= true ; } return $caps; } /*then only allow participants to trash their own topics*/ add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){ // apply only to delete_topic if ( $cap == "delete_topic" ){ // Get the post $_post = get_post( $args[0] ); if ( !empty( $_post ) ) { // Get caps for post type object $post_type = get_post_type_object( $_post->post_type ); // Add 'do_not_allow' cap if user is spam or deleted if ( bbp_is_user_inactive( $user_id ) ) { $caps[] = 'do_not_allow'; // Moderators can always edit forum content } elseif ( user_can( $user_id, 'moderate' ) ) { $caps[] = 'moderate'; // User is author so allow edit if not in admin } elseif ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) { $caps = array(); // Unknown so do not allow } else { $caps[] = 'do_not_allow'; } } } // return the capabilities return $caps; } //then redirect to the forum after trashing topic add_action('bbp_template_redirect', 'ST_trash_topic_check', 8); //check if topic has been trashed by author and show forum if it has function ST_trash_topic_check() { $topic_slug = get_option( '_bbp_topic_slug') ; //quick check if we need to do this function, so bail if not a topic if (strpos($_SERVER['REQUEST_URI'], $topic_slug) == FALSE) return ; $forum_slug = bbp_get_root_slug() ; //if check is set (ie we prefix forums with the forum slug) then part 1 will be forum slug and part 2 will be topic slug, if not part 1 will be topic slug $check = bbp_include_root_slug() ; $link = explode('/',$_SERVER['REQUEST_URI']); //next we need the topic id (post id) of the topic so we need to check if it is a topic and if so, find the topic id if (is_user_logged_in() && $check && $link[1] == $forum_slug && $link[2] == $topic_slug ) { $post = bsp_get_page_by_slug( $link[3], OBJECT, 'topic' ); $login_check=1 ; } elseif (is_user_logged_in() && empty($check) && $link[1] === $topic_slug) { $post = bsp_get_page_by_slug( $link[2], OBJECT, 'topic' ); $login_check=1 ; } //now we need to check if the topic has been trashed by author if (!empty ($login_check) && $post->post_status == 'trash' && $post->post_author == get_current_user_id() ) { $topic_id = $post->ID; //then redirect to the forum we came from $forum = bbp_get_forum_permalink (bbp_get_topic_forum_id ( $topic_id )) ; wp_redirect ($forum) ; exit ; } else return ; }I’ll add this function into my style pack plugin shortly
March 2, 2019 at 9:12 am #198981In reply to: 100 is limit for email notifications
Antipole
ParticipantYes AsynCRONousbbPress Subscriptions works out of-the-tin as described. But it turns a single email with 123 Bcc addressees into 123 single addressee emails, which breaks my ISP’s limit of 100 emails/hour. Sigh!
I have finally achieved my own plugin which hooks onto wp_mail() and which chops up outgoing emails into multiple emails with a configured maximum Bcc addressee limit. So with my ISP’s limit of 10 addressees, my 123 notifications get sent in 12 emails each with 10 addressees plus 1 with the last 3.
It works with all outgoing emails that supply the Bcc addresses in an array (as does bbPress) or a flat list (as does Subscribe2 for WP post notifications).
March 1, 2019 at 1:37 pm #198970In reply to: Sort Topics Column By Number of Likes (Favorites)
Robin W
Moderatornot an easy option.
yes favorites are stored against a user.
This gives the difficulty that you either:
a) count favorites on then fly – ie on every page load you would cycle through each user and log the topics they have favorited and count them into an array – this will slow the site and it has to happen on every page load. you’d then store these into post meta.
b) create some code that will count these using cron every so often, and update post meta
c) link to the favorite button. So it would need to add when favorited and deduct when unfavorited. then you would need to allow for topics being trashed etc.a) is the easiest, but still a chunk of code and has site implications
b) is probably the most practical, but will only be as current as you run cron, so could be say an hour out of date
c) is a real bunch of code I suspect, but would be the best solution on a big website.March 1, 2019 at 10:49 am #198969Topic: Sort Topics Column By Number of Likes (Favorites)
in forum Troubleshootingmattbru
ParticipantI would like to sort the topics by the number of likes column on the admin edit screen.
This is what ive got:
<?php // make columns sortable ------------------------------------------------- // define which columns to be sortable add_filter( 'manage_edit-topic_sortable_columns', 'topic_likes_table_sorting' ); function topic_likes_table_sorting( $columns ) { $columns['likes_count'] = 'likes_count'; return $columns; } // add sortable to meta key add_action( 'pre_get_posts', 'likes_orderby' ); function likes_orderby( $query ) { if ( ! is_admin() ){ return; } $orderby = $query->get( 'orderby'); if ( 'likes_count' == $orderby ) { $query->set('meta_key','bbpress_topic_like_button_like'); $query->set('orderby','meta_value_num'); } }I dont think there is a meta_key for favorites stored in the topic post_meta? I’m setting the number in the column by using the following:
$topic_id = bbp_get_topic_id($id); $likes_count = bbp_get_topic_favoriters($topic_id);I think the favorites are stored with the users metadata. So my best guess is that ill need to write a function that stores/updates the number of favorites inside the post meta. Then and only then can I sort the posts by that new metakey. Can anyone point me in the right direction with this?
Thank you!
February 28, 2019 at 3:02 pm #198948aidan1387
ParticipantI’m trying to import IPB database to bbPress with “Tools>Forums>Import Forums”.
But I always get a log that nothing is converted:Conversion Complete No reply_to parents to convert No replies to convert No tags to convert No super stickies to stick No stickies to stick No topics to convert No forum parents to convert No forums to convert No passwords to clear No users to convert Starting ConversionSelect Platform == Invision.
IP.Board version is v3.4.6.
How I could troubleshoot this? Where should I start at least?.February 28, 2019 at 6:10 am #198935In reply to: How to let Authors delete their own posts?
byzane
ParticipantSorry I misspoke. I was unable to run the code through my functions.php file, but it seems to be functioning through a snippet plugin:
My bad.
February 28, 2019 at 5:09 am #198933In reply to: How to let Authors delete their own posts?
byzane
ParticipantI’ve been doing a lot of research and I am wondering the same thing. The closest I have found was this:
However, that was posted 2 years ago and it seems the code doesn’t work anymore. Ironically, @robin-w it’s your modification xD. Would you mine dropping some insight as to why the code isn’t functioning properly anymore, please. 🙁
February 28, 2019 at 4:48 am #198932In reply to: How do I change the breadcrumb?
Robin W
Moderatorput this in your child theme’s functions file
function rew_breadcrumbs ($args) { $args['home_text'] = 'your new words here'; return $args ; } add_filter('bbp_before_get_breadcrumb_parse_args', 'rew_breadcrumbs');or use
once activated go to
dashboard>settings>bbp style pack>Breadcrumbs
February 28, 2019 at 1:59 am #198924Topic: Forum Messed up…
in forum Troubleshootingryolu22
ParticipantHay. New here. I tried to create a theme from scracth using pure html php and etc
At first, it was normal. It functions normally and the UI is not as messed up as right now.
And now out of anything, it suddenly messed up. Checkout my website here if you wanna see it https://psikologipolda.com/konsul-online/
I tried uninstalling bbpress, tried using different way of calling the forums and it still doesn’t work. Try looking at the css and tweak it, still doesn’t change.
Any idea? or any place I should edit my code?
FYI the page only used:
the content.php (that is used as a template for any content including the forum)
and the custom template for that page only.phpFebruary 25, 2019 at 5:28 am #198850In reply to: Newby Question
Robin W
Moderatorput this in your theme’s custom css area
.bbp-author-ip { display : none !important ; }February 24, 2019 at 3:43 pm #198817In reply to: Cannot edit replies in the back end
amnion
ParticipantIt seems to be an issue finding all the replies. In the database all those posts have the type “reply” as post_type. I don’t get it. The link matches the format for forums and topics, which are able to find all the posts just fine.
…/wp-admin/edit.php?post_type=reply
In addition to this, all the reply post authors are being input as 0, which makes them anonymous. I have that unchecked in the settings.
Is there a way to permanently delete bbpress and all its contents so I can reinstall fresh? EDIT: I found the answer to this question. https://codex.bbpress.org/getting-started/installing-bbpress/deleting-bbpress/
February 24, 2019 at 1:41 pm #198804In reply to: bbp_has_forums returning wrong value
Robin W
Moderatorbbp_has_forumms is just a forum version of wordpress has_posts.
The code you first posted – where is it, in your functions, in a plugin or where?
February 24, 2019 at 4:52 am #198799Robin W
Moderatorok, given that I probably amswered your original Q too literally let’s re-phrase that –
bbpress requires you to have an account on your website that is hooked to the wordpress software running on your website – which is what my original answer was. The username, password and all other details are only held only on your website. Nothing is passed to any other site (unless you add code to do so).
You are not required to have a wordpress.org username to use bbpress
February 23, 2019 at 4:09 pm #198793In reply to: Create New Topic – At the top of the forum page
w3215
ParticipantSorry–I think there was a typo earlier. The shortcodes are here:https://codex.bbpress.org/features/shortcodes/
Shortcode for create new topic page: [bbp-topic-form]
for new topic specific to an id: [bbp-topic-form forum_id=$forum_id]February 23, 2019 at 3:15 pm #198792In reply to: Create New Topic – At the top of the forum page
w3215
ParticipantHi There. I am new to bbpress, but I had a similar requirement, and I believe the following works:
1) Create a page where users can create a new topic. To do this, you can use one of these shortcodes: for new topic page: [bbp-topic-form]
for topic specific to forum id: [bbp-topic-form]2) Put a link to this page in the menu. (so in your menu, have a “Create a New Topic” link that takes you to the new topic page).
February 21, 2019 at 3:53 pm #198760In reply to: bbp_has_forums returning wrong value
Pleiades
ParticipantThanks, Robin W.
It’s a site I inherited with 100+ plugins. I’m trying to unravel the necessary from the superfluous but too many things keep breaking.I’m trying to put traps in the code to see where conflicts are occurring. It seems like bbp_has_forums calls methods that call methods that call methods…
I would appreciate if someone could help shortcircuit this process and point me to the place where the actual test is happening.
Please forgive my snarky comment earlier. This site has been a cluster and I’ve been frustrated by a long list of plugins with no doc and no response to developers.
February 21, 2019 at 2:25 pm #198758Robin W
Moderatortotally untested but try
function rew_status_transitions( $post ) { if ( $post->post_type == 'reply') { $topic = bbp_get_reply_topic_id ($post->ID) ; //update the post meta update_post_meta ($topic, '_bbp_last_active_time' , $post->post_date) ; } } add_action( 'future_to_publish', 'rew_status_transitions', 10, 1 );February 21, 2019 at 2:08 pm #198757In reply to: bbp_has_forums returning wrong value
Robin W
Moderatorit’s not much of a codex, but it’s the only one there is! I wrote quite a lot if it when I started using bbpress – I’m just a bbpress user who helps on here. If you’d like to contribute, post suggested improvements and I’ll add them – just saying 🙂
So if your code was working a few days ago, and it now isn’t, then you must have upgraded the theme, a plugin or changed something else. Without knowing what it’s hard to help.
February 21, 2019 at 2:06 pm #198756neon67
ParticipantIt’s working! Great!
1.New scheduled topic: time of publication and the timestamp in tracker coincide now!
2.Old topic (written 5 years ago) after time-correction for today – appear in the tracker correctly!
3.But, does not work for scheduled replay in topic. If replace the word “topic” for word “replay” in the code – will this work?February 20, 2019 at 4:39 pm #198735Topic: bbp_has_forums returning wrong value
in forum TroubleshootingPleiades
ParticipantI have a bbPress forum integrated with WooCommerce.
Until a few days ago it was working fine, but now$uid = bbp_get_current_user_id(); if ( bbp_has_forums( array( 'author' => $uid )) ) :returns bool(false) regardless of the user or user role.
On a side note, when searching codex.bbpress.org, the results I (don’t) get:
bbp_get_current_user_id – “Sorry, no posts matched your criteria.”
bbp_has_forums – “Sorry, no posts matched your criteria.”
bbp_forums – “Sorry, no posts matched your criteria.”
bbp_the_forum – “Sorry, no posts matched your criteria.”I understand these are just wrappers for WP_Query, but there are some obviously also forum-specific options. It doesn’t seem like much of a codex. Just saying.
February 19, 2019 at 6:20 pm #198708Robin W
Moderatorthis is more complicated than it as first looks, as there is forum data that needs updating
but as a start
function rew_status_transitions( $post ) { if ( $post->post_type == 'topic') { //update the post meta update_post_meta ($post->ID, '_bbp_last_active_time' , $post->post_date) ; } } add_action( 'future_to_publish', 'rew_status_transitions', 10, 1 );February 18, 2019 at 6:48 am #198659In reply to: Links in new topic
Oaz
Participantyes, apostrophes are okay now, with same result as before : links do not appear anymore in new topics. i disable the code, links display…
So strange this function is not in bbpresscore, I suppose many of us need it..
Anyway, thank you so much for your help and patience Robin. I spent much time on this without results. I think I’ll just lokk for another system than bbpress for my forum..
-
AuthorSearch Results