tharsheblows (@tharsheblows)

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 84 total)

  • tharsheblows
    Participant

    @tharsheblows

    @pathardepavan — post_parent is in the posts table rather than postmeta so instead of updating post meta, update the object in wp_posts. So your update callback function (update_topic_post_parent) would be something like:

    
    function update_topic_post_parent( $value, $object, $field_name ){
    $update_post_parent = array(
    'ID' => (int)$object->ID, // the ID of the topic you just created
    'post_parent' => (int)$value ); // whatever you want your post_parent to be as an int. You could use $field_name for 'post_parent' here but I tend to whitelist 
    
    wp_update_post( $update_post_parent )
    }

    and you should be able to get the post_parent from the $object directly in your get callback I think.

    Also if you’re using one of the latest versions of the plugin, you should use register_rest_field as register_api_field has been deprecated.

    (I’m doing this without any testing, sorry, so it might be incorrect! But I think that’s somewhere close to the answer maybe πŸ™‚ )


    tharsheblows
    Participant

    @tharsheblows

    πŸ™‚ I love that tool too! If you look at https://developers.google.com/speed/pagespeed/insights/ you might get some ideas about what’s slowing it down. It’s the latency that’s taking so long?

    Wow for the 8000 query sitemap!

    I have a couple of pages which load slower than I’d like but have an excellent host so when the site gets hammered it doesn’t slow it down further. They also provide caching so I can’t give you any advice on W3 Total Cache except that you might try tweaking your settings.


    tharsheblows
    Participant

    @tharsheblows

    @pyronaught, if it’s a local install, could you look at the queries to see which ones are super slow? I use https://wordpress.org/plugins/query-monitor/ for things like that.

    (I mean look at them and post them here so we can figure out where exactly the problem is! No worries if that’s not possible or you just don’t feel like it. πŸ™‚ )


    tharsheblows
    Participant

    @tharsheblows

    This is a result of a change in WordPress. I had this too – I don’t allow users to change their nickname so the nickname field on the edit form was disabled and didn’t submit (as was the intent). What I did was make the nickname field “readonly” rather than “disabled” and then added this in (you could add it to your functions.php)

    user_nickname_is_login( $meta, $user, $update ){
    	$meta['nickname'] = $user->user_login;
    	return $meta;
    }
    add_filter( 'insert_user_meta', 'user_nickname_is_login', 10, 3 );

    This sets the nickname as the user_login so you would change it to whatever the nickname should be. That function forces the nickname to be what I want — I know the field in the profile was readonly but it was still editable using dev tools and I didn’t want that!


    tharsheblows
    Participant

    @tharsheblows

    Yes, there’s an error with some of the menu_order bits. In addition to @nesiditsa’s edit (the same as this patch: https://bbpress.trac.wordpress.org/changeset/5392) you might need to apply these as well: https://bbpress.trac.wordpress.org/changeset/5338


    tharsheblows
    Participant

    @tharsheblows

    Thanks. The issue was introduced in WordPress 4.4 and there’s a patch available now. Could you test it to see if it makes it work for you? https://core.trac.wordpress.org/ticket/35084


    tharsheblows
    Participant

    @tharsheblows

    @t3_rrY — I think you’d use the mandrill_payload filter as explained here: http://blog.mandrill.com/own-your-wordpress-email-with-mandrill.html

    You could add it into @korobochkin’s code. I haven’t tried it – I’m not sure how the template is handled (I don’t use them) but that’s where I start. You can also simply add html to the message in the functions above, although for anything the least bit complicated design-wise, a template would be the way to go.

    I’ve just started using Mandrill; it’s great, isn’t it?

    In reply to: Group Forums

    tharsheblows
    Participant

    @tharsheblows

    Oh no! If you want to check if an individual forum is associated with a group, use the function above: bbp_is_forum_group_forum( bbp_get_forum_id() ) where bbp_get_forum_id() is the forum id (you might have to get it in a different way depending on what you’re doing!).

    Good luck!

    In reply to: Group Forums

    tharsheblows
    Participant

    @tharsheblows

    Ah ha! I see what you mean (maybe). So something in content-single-forum.php like this?

    <?php 
       if(  bbp_is_forum_group_forum( bbp_get_forum_id() )){
          bbp_get_template_part( 'form',       'topic'     );
       }else{
          echo '<a href="/">You could link to your form or whatever else here.</a>';  
       } 
    ?>

    rather than what’s there now:
    <?php bbp_get_template_part( 'form', 'topic' ); ?>

    Then you could use the shortcode [bbp-topic-form] on a new page and link to that page.


    tharsheblows
    Participant

    @tharsheblows

    I don’t know, sorry, but can they re-set them using the lost password link on the login page? I think that’s what I’d ask my users to do. (I realise that’s not the solution you want, though!)

    In reply to: Group Forums

    tharsheblows
    Participant

    @tharsheblows

    Ok — again, I think this is what you mean. It might not be! I’ve left in some bits that will show you exactly what’s happening.

    <?php while ( bbp_forums() ) : $forum = bbp_the_forum();
       // if it's a group forum, then this is true
       if(  bbp_is_forum_group_forum( bbp_get_forum_id() )){
          echo '<strong>The following *is* a group forum:</strong>';
          // this is the bit you would change to your new template. And take out those echos, they're just something I find useful and thought you might too! :)
          bbp_get_template_part( 'loop', 'single-forum' );
       }
       // if it's not a group forum, do this
        else{
          echo '<strong>The following *is not* a group forum:</strong>';
          bbp_get_template_part( 'loop', 'single-forum' ); 
       }
    ?>

    Slightly off topic, I think that winky icon in my previous post looks a bit creepy. It might be just me though.

    In reply to: Group Forums

    tharsheblows
    Participant

    @tharsheblows

    So what you want is if a forum is in a group, it gets one template and if it’s not in a group, it gets another? eg in loop-forums.php you want something like:

    <?php while ( bbp_forums() ) : bbp_the_forum(); ?>
    
      if( this is a group forum ){
       <?php bbp_get_template_part( 'loop', 'single-group-forum' ); ?>
      }
      else{
        <?php bbp_get_template_part( 'loop', 'single-forum' ); ?>
      }
    
    <?php endwhile; ?>

    where bpp_get_template_part( ‘loop’, ‘single-group-forum’ ); gets a template part named “loop-single-group-forum.php” that you’ve created, probably by copying and modifying “loop-single-forum.php”.

    I’d think that’d be possible but while I’m looking for whatever goes in that if statement, want to check that that’s what you mean! No worries if not, one of my core competencies is misreading and misunderstanding posts. πŸ˜‰


    tharsheblows
    Participant

    @tharsheblows

    In some cases, it might be because the subscription emails are now being sent with all subscribers bbc’ed in rather than individually from a created no-reply address. The reason for the change is that posting new replies or topics was taking too long as it cycled through sending those emails. However, for some people (myself included), that wasn’t an issue.

    You can go back to the previous way as outlined here (as I mentioned, I have similar code in a plugin) but it should work if you put it in a file called bbp-functions.php in your bbpress theme.

    Actually, you might — after doing all the things you would do before you install a new plugin — try going back to the previous way with this: MJJ bbP 2.5.3 Subs. It does what it says on the tin, just uses the old functions from bbPress 2.5.3 to send subscription mails. Again, it might slow down new replies or topics. It doesn’t for me but just keep an eye on it.


    tharsheblows
    Participant

    @tharsheblows

    Like @korobochkin said, the way emails are sent was changed in the last update of bbPress – it used to send individual emails, now they are bcc’ed into one email.

    If it was working for you before or you just want to try this, you can change it back to the old way eg: https://bbpress.org/forums/topic/admin-subscription-emails/#post-154515


    tharsheblows
    Participant

    @tharsheblows

    If you want to add fields (including captchas) to your registration form, you can make a custom registration form – there are a lot of plugins that allow you to do this and tutorials on creating your own. I use Gravity Forms but I’m sure many others are good too.

    One of the best things to me about WordPress is its user management; it’d be a shame not to use it! πŸ™‚


    tharsheblows
    Participant

    @tharsheblows

    You can get the displayed user role (eg “Participant”, “Keymaster” etc) of the current user using bbp_get_user_display_role( get_current_user_id() ) although you’d need to check if they were logged in first. The template to modify is content-archive-forum.php.


    tharsheblows
    Participant

    @tharsheblows

    The reason for this is that sending out subscription emails one by one was appreciably slowing down some large sites, so in the last update they switched to bcc’ing in subscribers.

    It’s fairly straightforward to change how the subscription emails are handled once you know how. If you unhook ‘bbp_notify_topic_subscribers’ you can then hook in your own subscription function.

    Below is similar to what I did – I have it in a plugin but you could put it in your bbpress-functions.php file too, I think – this should be in a child theme. If you do this, please test it first as this is simply an example and not necessarily working code. I’ve gone ahead and simply pasted in the function that was used in the previous version of bbPress so you don’t have to find it.

    //custom topic subscription emails, unhook old function, hook in new one
    remove_action( 'bbp_new_reply',    'bbp_notify_topic_subscribers', 11, 5 );
    add_action( 'bbp_new_reply',    'mjj_bbp_notify_topic_subscribers', 11, 5 );
    
    /** 
    * from bbpress / includes / common / functions.php
    * this is taken from 2.5.3 - I've left in all comments to make it easier to understand
    **/
    
    /** Subscriptions *************************************************************/
    
    /**
     * Sends notification emails for new replies to subscribed topics
     *
     * Gets new post's ID and check if there are subscribed users to that topic, and
     * if there are, send notifications
     *
     * @since bbPress (r2668)
     *
     * @param int $reply_id ID of the newly made reply
     * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     * @uses bbp_get_reply_id() To validate the reply ID
     * @uses bbp_get_topic_id() To validate the topic ID
     * @uses bbp_get_forum_id() To validate the forum ID
     * @uses bbp_get_reply() To get the reply
     * @uses bbp_is_reply_published() To make sure the reply is published
     * @uses bbp_get_topic_id() To validate the topic ID
     * @uses bbp_get_topic() To get the reply's topic
     * @uses bbp_is_topic_published() To make sure the topic is published
     * @uses bbp_get_reply_author_display_name() To get the reply author's display name
     * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id,
     *                    topic id and user id
     * @uses bbp_get_topic_subscribers() To get the topic subscribers
     * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the
     *                    message, reply id, topic id and user id
     * @uses apply_filters() Calls 'bbp_subscription_mail_title' with the
     *                    topic title, reply id, topic id and user id
     * @uses apply_filters() Calls 'bbp_subscription_mail_headers'
     * @uses get_userdata() To get the user data
     * @uses wp_mail() To send the mail
     * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id,
     *                    topic id and user id
     * @return bool True on success, false on failure
     */
    function mjj_bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) {
    
    	// Bail if subscriptions are turned off
    	if ( !bbp_is_subscriptions_active() )
    		return false;
    
    	/** Validation ************************************************************/
    
    	$reply_id = bbp_get_reply_id( $reply_id );
    	$topic_id = bbp_get_topic_id( $topic_id );
    	$forum_id = bbp_get_forum_id( $forum_id );
    
    	/** Reply *****************************************************************/
    
    	// Bail if reply is not published
    	if ( !bbp_is_reply_published( $reply_id ) )
    		return false;
    
    	/** Topic *****************************************************************/
    
    	// Bail if topic is not published
    	if ( !bbp_is_topic_published( $topic_id ) )
    		return false;
    
    	/** User ******************************************************************/
    
    	// Get topic subscribers and bail if empty
    	$user_ids = bbp_get_topic_subscribers( $topic_id, true );
    	if ( empty( $user_ids ) )
    		return false;
    
    	// Poster name
    	$reply_author_name = bbp_get_reply_author_display_name( $reply_id );
    
    	/** Mail ******************************************************************/
    
    	do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
    
    	// Remove filters from reply content and topic title to prevent content
    	// from being encoded with HTML entities, wrapped in paragraph tags, etc...
    	remove_all_filters( 'bbp_get_reply_content' );
    	remove_all_filters( 'bbp_get_topic_title'   );
    
    	// Strip tags from text
    	$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
    	$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
    	$reply_url     = bbp_get_reply_url( $reply_id );
    	$blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    
    	// Loop through users
    	foreach ( (array) $user_ids as $user_id ) {
    
    		// Don't send notifications to the person who made the post
    		if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author )
    			continue;
    
    		// For plugins to filter messages per reply/topic/user
    		$message = sprintf( __( '%1$s wrote:
    
    %2$s
    
    Post Link: %3$s
    
    -----------
    
    You are receiving this email because you subscribed to a forum topic.
    
    Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
    
    			$reply_author_name,
    			$reply_content,
    			$reply_url
    		);
    
    		$message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id );
    		if ( empty( $message ) )
    			continue;
    
    		// For plugins to filter titles per reply/topic/user
    		$subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id );
    		if ( empty( $subject ) )
    			continue;
    
    		// Custom headers
    		$headers = apply_filters( 'bbp_subscription_mail_headers', array() );
    
    		// Get user data of this user
    		$user = get_userdata( $user_id );
    
    		// Send notification email
    		wp_mail( $user->user_email, $subject, $message, $headers );
    	}
    
    	do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
    
    	return true;
    }

    tharsheblows
    Participant

    @tharsheblows

    Thanks. I wonder why that is.

    Did you, by any chance, run the “Remap existing users to default forum roles” tool? I wouldn’t have because I have waaaay too many people that have the “blocked” bbPress role but I didn’t change from “subscriber” in their WP role.

    Just curious if there’s a case to be made for a tool to do the same but just for Keymaster capabilities. Or something. I’m not quite familiar with all of it to know the right way to handle it.

    Anyway, thank you for letting me know! πŸ™‚ I was super curious.


    tharsheblows
    Participant

    @tharsheblows

    Oh I’m glad you got it sorted! I read this and meant to reply but forgot.

    Do you remember which capabilities were missing? I’m curious as to why they weren’t active.

    In reply to: Moderate forum?

    tharsheblows
    Participant

    @tharsheblows

    Hi – when you’re logged in as an admin, you should be able to do this from the front end as well as in admin. There should be a little bar of links at the top of each post like the one in the image on the right here: http://www.ilovecolors.com.ar/add-private-content-to-bbpress-topics-and-replies/ (the plugin has nothing to do with this issue, it’s just the best image I could find).

    If you don’t see that, make sure your bbPress role is set to Keymaster. And if that is right, make sure another plugin or your theme isn’t causing them not to appear by disabling all plugins then re-enabling them one by one and switching to the Twenty Fourteen theme.


    tharsheblows
    Participant

    @tharsheblows

    Hi – the 1000 posts thing is a known issue which will be fixed in 2.6.

    In the meantime do these two steps in order (but test them first! always test first):
    1. change this code: https://bbpress.trac.wordpress.org/ticket/2615
    2. run the “Recalculate the position of each reply” tool in Tools -> Forums

    Again, test it all first before doing it to your live site.

    Are you using bbPress 2.5.4? Prior to that, sending subscriptions was slowing things down, too.


    tharsheblows
    Participant

    @tharsheblows

    I would think that BuddyPress should be fine. But do you have any other plugins? If you have any more, try deactivating them all (bar bbPress and BuddyPress), seeing if the problem is still there and then reactivating them one by one to find the offender.


    tharsheblows
    Participant

    @tharsheblows

    Shoot.

    The problem is, I think, that current_user_can( ‘bbp_forums_admin’ ) and the topics / replies equivalents are returning false for your admins / keymasters in bbpress/bbpress.php register_post_type() starting on 473 (you want ‘show_ui’ => true when registering the post types). Oddly (?) I can’t find the bbp_forums_admin etc capabilities anywhere.

    I am just checking here but you don’t have a cache or anything like that enabled, do you?

    I’m just about to go to bed but will test a couple of work-arounds tomorrow sometime.


    tharsheblows
    Participant

    @tharsheblows

    Could you check to see if your admins have the bbPress role of “keymaster”? If not, change that and see if it works.

    I’ve just reproduced the problem and had to do that. Having an “administrator” WP role was not enough.

    Just want to know if that’s the issue! Thanks.


    tharsheblows
    Participant

    @tharsheblows

    I can’t reproduce this on a clean install of WP 4.0 with bbPress 2.5.4 and Twenty Fourteen theme. What other plugins are you using? I’ve tried it both with Join My Multisite and this pluginhttps://wordpress.org/plugins/multisite-plugin-manager/ (tried them separately, I mean) and both work.

    Can you give any more details? Which theme are you using?

Viewing 25 replies - 1 through 25 (of 84 total)