Loc Pham (@phamdacloc)

Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)

  • Loc Pham
    Participant

    @phamdacloc

    Repairing the counter via Tools menu did the trick. Thank you for your help.


    Loc Pham
    Participant

    @phamdacloc

    Hi Pascal,
    Yes, I passed in the user id for admin and I’ve always got “0” back and admin had created many topics already.

    bbp_get_user_post_count(1, false);

    Thanks.


    Loc Pham
    Participant

    @phamdacloc

    I registered a new rest endpoint and wrote functions to retrieve all the replies with the code below. Although the code works, I’m not really happy with it because I’m not able utilize built in filtering (i.e. paged, order, posts_per_page… etc). This code is not optimize because it has no pagination and will retrieve all replies at once (can be bad if there are thousands of records).

    
    function ldp_get_topic_replies( $data ) {
    	$topicID = $data['id'];
    	
    	// Get an array of all replies belonging to a specific topic
    	$repliesID = bbp_get_all_child_ids($topicID, bbp_get_reply_post_type());
    	
    	$response = array();
    	
    	foreach ($repliesID as $replyID) {
    		$response[] = ldp_get_topic_reply($replyID);
    	}
    	
    	return $response;
    }
    
    function ldp_get_topic_reply( $replyID ) {
    	$reply = array(
    		'author_name'	=> bbp_get_reply_author_display_name($replyID),
    		'author_email'	=> bbp_get_reply_author_email($replyID),
    		'author_url'	=> bbp_get_reply_author_url($replyID),
    		'author_avatar'	=> get_avatar_url(bbp_get_reply_author_id($replyID)),
    		'link'			=> bbp_get_reply_url($replyID),
    		'reply_to'		=> bbp_get_reply_to( $replyID ) == 0 ? NULL : bbp_get_reply_to( $replyID ),
    		'topic_title'	=> bbp_get_reply_topic_title($replyID),				
    		'meta'			=> bbp_get_reply($replyID),
    	);
    	
    	return $reply;
    }
    

    Loc Pham
    Participant

    @phamdacloc

    Hi Pascal, thanks the these links. However those addressed the problem seen in WP REST Api version 1 and version 2 is the refactor code for WP REST API which will eventually go into WordPress Core. Version 2 is what I’m using and it doesn’t work as explain in those blog.


    Loc Pham
    Participant

    @phamdacloc

    I’m not allow to change bbp_get_reply() but I was able to work around my problem by calling get_post_time('c', false, $replyID, false) where ‘c’ is iso 8601 format.


    Loc Pham
    Participant

    @phamdacloc

    This is superb. Thanks Pascal.


    Loc Pham
    Participant

    @phamdacloc

    With a combination of two methods, I was able to get the number of topics per tag. These methods query the taxonomies of bbPress’ topic-tag:

    $tagList = get_the_terms($post->ID, bbp_get_topic_tag_tax_id());

    The output of $tagList is as follow and ‘count’ is what i’m interested in:

    {
    term_id: 24
    name: “Presidential”
    slug: “presidential”
    term_group: 0
    term_taxonomy_id: 24
    taxonomy: “topic-tag”
    description: “”
    parent: 0
    count: 3
    object_id: 155
    filter: “raw”
    }

    Hope this helps others.


    Loc Pham
    Participant

    @phamdacloc

    Actually, there’s a function for this already and it’s called: bbp_get_topic_favoriters($postID).

    Hope this helps others looking for something similar.

    -Loc


    Loc Pham
    Participant

    @phamdacloc

    My post stripped the bracket in my endpoints, it should be the following instead:

    http://localhost:8888/wp-json/wp/v2/topic?filter[forum_type]=sports
    http://localhost:8888/wp-json/wp/v2/topic?filter[forum]=sports
    In reply to: Is there a REST API?

    Loc Pham
    Participant

    @phamdacloc

    I’m also looking for the REST API for bbPress but unable to find info on it either.


    Loc Pham
    Participant

    @phamdacloc

    Thanks everyone for posting your method of inserting inline images. So are those methods which you’ve posted a hack? Will it expose security risk? Why don’t bbPress support this capability as the thread has been asked over 3 years ago?

Viewing 11 replies - 1 through 11 (of 11 total)