Barry (@barryhughes-1)

Forum Replies Created

Viewing 25 replies - 26 through 50 (of 61 total)

  • Barry
    Participant

    @barryhughes-1

    I find it just a little disconcerting that this problem has been in the wild – stopping, for example, new users of the plugin from being able to set anything up – for almost 6 months now …

    In reply to: SDK/API

    Barry
    Participant

    @barryhughes-1

    Hi @fhasst1,

    (Let me start by noting it could very well be that you already know this—but something in your post made me want to call it out just in case you weren’t aware.)

    bbPress runs on top of WordPress. That’s important because it means if a user has logged into your (WordPress-driven) site/app then, by extension, they will have logged into the forum (insofar as bbPress will realize they are an authenticated user and will be able to identify them) … no need for a separate login.

    Also, I think it’s worth calling out the fact that when it comes to adjusting the way bbPress behaves, or building some new forum feature, there is a really quite extensive set of functions, hooks and methods available to you that make it a really awesome platform to build on.

    codex.bbpress.org


    Barry
    Participant

    @barryhughes-1

    2.6 (beta 2) is available for testing (if you haven’t already seen the announcement post) – so things are happening!


    Barry
    Participant

    @barryhughes-1

    50x type errors can cover a multitude of sins.

    Do you have access to the PHP or web server error logs, at all, and if so are you able to match up any notable entries that coincide with these errors?


    Barry
    Participant

    @barryhughes-1

    I don’t know of any existing solutions for this, but it’s a great idea!


    Barry
    Participant

    @barryhughes-1

    Hey Ludovic,

    Quoting a bbPress Codex entry on forum visibility and accessibility:

    Private – Only logged in registered users with a forum role can see these forums

    With that in mind, so long as the user is logged in and has been assigned to a forum role (ie, participant) – which can be set directly if required via the edit-user admin screen (ie /wp-admin/user-edit.php?user_id=xyz) – then they ought to be able to access the private forum.

    Does that help at all/am I misunderstanding?


    Barry
    Participant

    @barryhughes-1

    The reason I asked is because many of the classes you used in your last post aren’t ones I see in the regular reply editor – so I wondered if you had some sort of customizations in place.

    In reply to: Form to forum

    Barry
    Participant

    @barryhughes-1

    Notifications would normally be dispatched when the bbp_new_topic action fires.

    In this case, you’d either have to trigger that manually or else call bbp_notify_forum_subscribers() directly (or else craft a manual solution of your own).


    Barry
    Participant

    @barryhughes-1

    Share a URL?


    Barry
    Participant

    @barryhughes-1

    On the box-shadow front, you might find a specifier like:

    #wp-bbp_topic_content-editor-container .wp-editor-area

    Provides the specificity you need to apply a box shadow from a custom stylesheet (or custom CSS plugin).

    In reply to: Tag

    Barry
    Participant

    @barryhughes-1

    That should be possible, yes.

    There are a few ways you could go about this but the easiest is probably to make topic tags available to regular blog posts (that way, both can share the same taxonomy and you probably won’t need to worry about modifying the bbPress UI).

    If you really need to, you could go a step further and a) remove ‘regular tags’ from blog posts and b) rename topic tags so they simply read as ‘tags’. This would result in you having one type of tag everywhere.

    Bear in mind however that if you already have a bunch of existing topic and regular tags you would need to do some migration work unless you are prepared to lose one set.


    Barry
    Participant

    @barryhughes-1

    The WP Codex is a great starting point for learning how to do things like register a custom taxonomy … it comes to mind you might also want to explore plugins like Posts 2 Posts (which would offer an alternative way to go about this task).


    Barry
    Participant

    @barryhughes-1

    Though I think I understand the gist of what you’re trying to accomplish, I’m not completely clear about how you see the user experience shaking out. That said, a natural way to group like-things together is to use a taxonomy (think tags and categories).

    In this case, that might mean creating a new taxonomy especially for this task or it might mean extending an existing taxonomy (such as ‘topic tags’, such that they also work with pages and any other relevant post types).

    In reply to: New topics

    Barry
    Participant

    @barryhughes-1

    Something like this ought to do the trick:

    function bbp_add_recent_activity_view() {
    	bbp_register_view(
    		'active',
    		'Active topics',
    		array(
    			'meta_key'      => '_bbp_last_active_time',
    			'meta_type'     => 'DATETIME',
    			'meta_compare'  => '>=',
    			'meta_value'    => date_i18n( 'Y-m-d H:i:s', strtotime( '-1 day' ) ),
    			'max_num_pages' => 1,
    			'orderby'       => 'meta_value_num',
    			'show_stickies' => false
    		) 
    	);
    }
    
    add_action( 'bbp_register_views', 'bbp_add_recent_activity_view' );

    With this in place you should then be able to access a list of ‘active’ topics at:

    example.com/forums/view/active

    In terms of where to add this sort of code, there are a few options. One would be to create a new PHP file (starting with a <?php opening tag) at:

    wp-content/mu-plugins/bbpress-tweaks.php


    Barry
    Participant

    @barryhughes-1

    Just to add to Robin’s note, the textarea’s box-shadow is set to none by wp-includes/css/editor.css (which uses the same selector as you were using), so getting more specific with your rule is a good way to go here.

    In reply to: Form to forum

    Barry
    Participant

    @barryhughes-1

    Well, if you’re building on my example code you could make a few changes in order to get the information flowing back to the success message:

    # Find this line
    bbp_insert_topic( /* ... */ );
    
    # Change it: let's catch the post ID
    $topic_id = bbp_insert_topic( /* ... */ );
    
    # Find this line
    post_to_bbp_status( 'success' );
    
    # Change it: let's pass the post ID instead of 'success'
    post_to_bbp_status( $topic_id );
    
    # Find this condition
    if ( 'success' === post_to_bbp_status() )
    
    # Change it: test to see if it contains a post ID
    if ( is_numeric( post_to_bbp_status() ) )
    
    # Find the line
    return 'Thank you for your submission.';
    
    # Change it: display the new topic's permalink
    return 'Check your post: ' . get_permalink( post_to_bbp_status() );

    Note that these changes are untested, they don’t do any safety checks etc etc. However, I hope it gives you some ideas you can use to further develop your own solution 🙂


    Barry
    Participant

    @barryhughes-1

    Sounds like a great idea to me!

    In reply to: Form to forum

    Barry
    Participant

    @barryhughes-1

    I’m sure you could do that pretty easily.

    If a call to bbp_insert_topic() is successful it returns the post ID of the newly created topic. You can in turn pass that to get_permalink() which will provide you with the URL.

    get_permalink()


    Barry
    Participant

    @barryhughes-1

    Excellent, happy to hear it helped 🙂


    Barry
    Participant

    @barryhughes-1

    Forums, topics and replies live in the posts table (typically wp_posts but the prefix might be different in your case). Something like this may help:

    UPDATE wp_posts
    SET    post_author = 1
    WHERE  post_author = 0
    AND    post_type IN ( 'reply', 'topic' )

    Essentially it finds all replies and topics where the author ID is zero and updates them to be associated with some other user (I used user ID 1 in my example, obviously modify to suit).

    In reply to: Form to forum

    Barry
    Participant

    @barryhughes-1

    There is of course the [bbp-topic-form] shortcode that ships with bbPress itself … but if that’s unsuitable or if customizing it to meet your goals isn’t an option for any reason, then you could roll your own solution quite easily.

    Here is a (super simple) example of just that – it creates an extremely simple (single field!) form via the [post_to_bbp] shortcode and uses the submitted data to create a new forum topic. Of course, there is a great deal it doesn’t do that you’d probably want in place before using it in production, but it’s just an example after all 🙂


    Barry
    Participant

    @barryhughes-1

    No worries!


    Barry
    Participant

    @barryhughes-1

    Absolutely – I’m also still exploring this new territory, nice to have an ‘excuse’ to do so 😉


    Barry
    Participant

    @barryhughes-1

    This is great news!

    Unfortunately I did pretty much hit a fatal error straight away (I reported it and added a patch here – hopefully that was the right place/course of action) though I believe that will only impact those who test this out in a site that was already running bbPress, vs a clean installation.


    Barry
    Participant

    @barryhughes-1

    Additionally, as an example of how you can add pretty much anything you want to the JSON responses returned by the REST API:

    function bbpress_rest_api_replies_extra_data( WP_REST_Response $response ) {
    	if ( ! is_array( $response->data ) ) {
    		return $response;
    	}
    
    	foreach ( $response->data as $key => $single_item ) {
    		// Only modify replies
    		if ( bbp_get_reply_post_type() !== $single_item['type'] ) {
    			continue;
    		}
    
    		// Add the author's details using a custom format
    		$author_id = get_post( $single_item['id'] )->post_author;
    		$author = get_user_by( 'ID', $author_id );
    		$response->data[ $key ]['author'] = "{$author->display_name} <{$author->user_email}>";
    	}
    
    	return $response;
    }
    
    add_filter( 'rest_request_after_callbacks', 'bbpress_rest_api_replies_extra_data' );

    You could say this is a bit of a brute force hack and although when combined with my last snippet it successfully adds the author’s display name and email address to replies (not topics), it shouldn’t really be used for that purpose “as is”: it doesn’t escape the author details, you probably don’t want to expose their email addresses, plus it’s out of alignment with how author meta is returned for other post types … However, I felt it was worth sharing an example of how you can quite quickly add arbitrary fields to REST API output.

Viewing 25 replies - 26 through 50 (of 61 total)