Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 3,951 through 3,975 (of 32,517 total)
  • Author
    Search Results
  • #197529
    Robin W
    Moderator

    can you post the code that creates the field in the reply form please

    #197525
    mariririn
    Participant

    Yes, this code does not check URLs. And I write it in “functions.php”.

    mariririn
    Participant

    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.

    #197519
    Robin W
    Moderator

    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

    #197518
    Robin W
    Moderator

    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 ?

    #197515
    Robin W
    Moderator

    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.";
    
    ?>
    
    #197514
    chaaampy
    Participant

    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.

    #197499
    mariririn
    Participant

    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.

    #197495
    odevbul
    Participant

    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>
    #197494
    odevbul
    Participant

    @Robin I did that. Can I add codes to those who want to?

    #197488
    Robin W
    Moderator

    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( '&nbsp;', '',  $author_link );
    return $author_link;
    }

    Code Snippets

    #197472
    Foliferous
    Participant

    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.

    #197414
    Robin W
    Moderator

    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 ;
    }
    #197413
    eigodeasobo
    Participant

    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?

    #197411
    eigodeasobo
    Participant

    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.

    #197403
    mrwassen
    Participant

    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

    #197398
    Robin W
    Moderator

    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' );
    #197396
    Robin W
    Moderator
    $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 ) ;
    eigodeasobo
    Participant

    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>
    #197382
    simjohna
    Participant

    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.

    #197366
    mrwassen
    Participant

    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

    #197226
    Robin W
    Moderator

    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 ;
    
    }
    #197223
    mrwassen
    Participant

    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

    #197174
    Robin W
    Moderator

    yes if you know how to code

    the nearest action hook is

    ‘bbp_template_before_forums_index’

    #197172
    Robin W
    Moderator

    bbpress does not have that, and I’m not sure how to code it, so as a user I can’t help – sorry

Viewing 25 results - 3,951 through 3,975 (of 32,517 total)
Skip to toolbar