can you post the code that creates the field in the reply form please
Yes, this code does not check URLs. And I write it in “functions.php”.
I am implementing comment function by AJAX. At the moment wp insert post is used. However, this function does not have a key for entering three values of “reply attribute”.
In other words, I want to input three values “forum ID”, “topic ID” and “Reply To ID” with wp insert post.
It key is like the next “???” .
wp_insert_post(array(
'post_title' => (string)$_POST['replyTitle'],
'post_content' => (string)$_POST['replyContent'],
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'reply'
'???' => (string)$_POST['forumID'],
'???' => (string)$_POST['topicID'],
'???' => (string)$_POST['replyToID'],
), true);
How can I register these three values with wp insert post?
I look forward to your response.
as a temporary, add this to your functions file
add_action( 'bbp_template_after_forums_index' , 'rew_add_breadcrumb');
add_action( 'bbp_template_after_single_forum' , 'rew_add_breadcrumb');
add_action( 'bbp_template_after_single_topic' , 'rew_add_breadcrumb');
function rew_add_breadcrumb () {
bbp_breadcrumb();
}
I’ll look to add it to style pack shortly
so what is the code doing/not doing that you want it to ?
I presume you have $_POST[‘input_url’] set in either the reply post template or a function ?
I suspect that it doesn’t know which user you want displayed
untested but try this
<?php
$current_user_id = (int) bbp_get_current_user_id();
$topics = bbp_get_user_topic_count_raw($current_user_id);
$replies = bbp_get_user_reply_count_raw($current_user_id);
$totalTopics = $topics * 5;
$totalsReplies = $replies * 2;
$points = $totalTopics + $totalsReplies;
echo " points = $points.";
?>
WP : 5.0.2
bbPress : 2.5.14
Theme : Custom (built with _S)
Hi everyone,
Im trying to simply display the number of “points” earned by the current user (points = replies + topics), but outside the profile page (in my header actually, so basically on my whole website).
Here is what I tried :
<?php
$topics = bbp_get_user_topic_count_raw();
$replies = bbp_get_user_reply_count_raw();
$totalTopics = $topics * 5;
$totalsReplies = $replies * 2;
$points = $totalTopics + $totalsReplies;
echo ” points = $points.”;
?>
When Im on the user’s profile page, this code worked lovely, but when Im outside of this page, anywhere on my website, it displays nothing.
Any idea of what is exactly my issue ?
Cheers,
Chaaampy.
I want to check if the custom field at reply is “AllowedURL”.
If applicable to “AllowURL”, I would like to have the custom field value go into the database, but can you tell me the correct way to write the following code?
add_action( 'bbp_new_reply', 'bbp_save_reply_extra_fields', 10, 1 );
add_action( 'bbp_edit_reply', 'bbp_save_reply_extra_fields', 10, 1 );
function bbp_save_reply_extra_fields( $reply_id ) {
$input_url = $_POST['input_url'];
$AllowURL = [
'^http?://example.com/[^/]{10}$',
'^http?://example.net/[^/]{20}$'
];
foreach ( $AllowURL as $AU ){
if( @preg_match( '|'.$AU.'|', $input_url ) ) {
if ( isset($_POST) && $_POST['input_url']!='' ) {
update_post_meta( $reply_id, 'input_url', $_POST['input_url'] );
}
}
}
}
I look forward to your response.
bbpress/templates/default/bbpress/pagination-replies.php line:15
div class="bbp-pagination" temprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
<link itemprop="interactionType" href="http://schema.org/CommentAction" />
<div class="bbp-pagination-count" itemprop="userInteractionCount">
bbpress/templates/default/bbpress/loop-single-reply.php line:42
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<span itemprop="name"><?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
your template page.php edit
<article itemid="<?php the_permalink(); ?>" itemscope itemtype="http://schema.org/DiscussionForumPosting" id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?>>
<h1 class="post-title" itemprop="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
@Robin I did that. Can I add codes to those who want to?
put this in your functions file or in code snippets
add_filter( 'bbp_suppress_private_author_link', 'rew_remove_author_space' ) ;
function rew_remove_author_space ($author_link ){
$author_link = str_replace( ' ', '', $author_link );
return $author_link;
}
Code Snippets
Hello again! That space is bugging me, is there no way to remove it?
When you look at the code on the site itself it looks like it is this sign here which is causing spaces:
"
It also does that in other places. Can someone tell me why? And there’s no way to hide it through CSS either, because it has no class or id, so you can’t add display: none: to it.
try this
function rew_count_threaded_replies ($reply_id = 0) {
$meta_key = '_bbp_reply_to' ;
global $wpdb;
$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta where meta_key='$meta_key' AND meta_value = '$reply_id'" );
echo $user_count ;
}
Yes, I’d like to specify a reply to a topic and get the number of replies to it.
I am glad if there is a function like xxx below.
<?php
$topic_id = 1 ;
echo bbp_topic_reply_count( $topic_id ) ;
// 3
?>
<?php xxx(100) ;
// 2
?>
<?php xxx(101) ;
// 0
?>
<?php xxx(102) ;
// 0
?>
Do you have any sugesstions?
It is a code that specifies the topic ID and obtains the number of replies.
What I want to know is a code that specifies the reply ID and obtains the reply number.
Hi Robin,
Thanks for the suggested code. I tried it but it keeps returning nothing when specifying an existing forum ID. I checked that $attr contains the specified forum_id, but am unsure on how to troubleshoot bbp_forum_subscription_link().
Any help would be appreciated.
Thanks
Dennis
for
[bbp-subscribe-link forum_id=’557′]
this code (untested) should be close
function bp_subscribe_shortcode($attr) {
//must have a forum_id or we just return !
if (empty( $attr['forum_id'])) return ;
else $args['forum_id'] = $attr['forum_id'];
echo bbp_forum_subscription_link($args) ;
}
add_shortcode( 'bbp-subscribe-link', 'bp_subscribe_shortcode' );
$topic_id = 100 ;
$ count = bbp_get_topic_reply_count( $topic_id) ;
echo $count ;
or shorter
$topic_id = 100 ;
echo bbp_topic_reply_count( $topic_id ) ;
Is there a function to specify replyID and get the number of replies to it?
For example, if you have the following HTML, I would like to know about functions that can write “<?php xxx(100) ?>” and get “2”.
<div id="bbpress-forums">
<ul id="topic-1-replies" class="forums bbp-replies">
<li>
<div id="post-100">
<p>Hello!</p>
</div>
<li>
<ul class="bbp-threaded-replies">
<li>
<div id="post-101">
<p>Hi!</p>
</div>
<li>
<li>
<div id="post-102">
<p>Cheers!</p>
</div>
<li>
</ul>
</ul>
</div>
Yes, I study via your code previous to posting this and used it for instance of a way to add alternatives to the page.
It became because of reading your code that I become asking approximately using tabs. My purpose for this is that it might deliver the customers a clear distinction between ‘middle’ and ‘custom’ options whilst nevertheless maintaining all options on the same web page.
Just thought it might be precise, cool, and offer but another degree of the company to bbPress.
Hi simjonna,
Thanks for your reply. I think you have misunderstood my question. What I am looking for is the code to create a shortcode which returns the subscribe/unsubscribe link. It would be added to my theme’s functions.php and look something like this:
function bp_subscribe_shortcode() {
... logic to create a URL to subscribe, unsubscribe...
}
add_shortcode( 'bbp-subscribe-link', 'bp_subscribe_shortcode' );
It would accept one input: the ID of the forum, e.g.:
[bbp-subscribe-link forum_id=’557′]
It can then be placed in a page or a post etc.
Any help appreciated.
Thanks
Dennis
yes, this should work – add this to the functions file in your child theme
add_filter( 'bbp_new_topic_redirect_to', 'rew_forum_redirect_topic' , 10 ,3 ) ;
add_filter( 'bbp_new_reply_redirect_to', 'rew_forum_redirect_reply' , 10 ,3 ) ;
function rew_forum_redirect_topic ($redirect_url, $redirect_to, $topic_id ){
$forum_id = bbp_get_topic_forum_id($topic_id);
$redirect_url = bbp_get_forum_permalink( $forum_id ) ;
return $redirect_url ;
}
function rew_forum_redirect_reply ($redirect_url, $redirect_to, $reply_id ){
$forum_id = bbp_get_reply_forum_id($reply_id);
$redirect_url = bbp_get_forum_permalink( $forum_id ) ;
return $redirect_url ;
}
Hi,
Would it be possible to create a shortcode which returns the subscribe/unsubscribe link for a given forum ? The end result would be something along the lines of:
[bbp-subscribe-link forum_id=’557′]
The returned link would display “Subscribe” or “Unsubscribe” depending on the current state of subscription.
This would allow a little more flexibility in placement of the link in the top part of a page with the forum embedded.
Any help would be appreciated.
Thanks
Dennis
yes if you know how to code
the nearest action hook is
‘bbp_template_before_forums_index’
bbpress does not have that, and I’m not sure how to code it, so as a user I can’t help – sorry