ghoush (@ghoush)

Forum Replies Created

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

  • ghoush
    Participant

    @ghoush

    Just a note to everyone who might find this. It’s been more than 4 years, and this code still works great.

    For anyone looking to add signatures on BuddyBoss Platform instead of bbPress/BuddyPress, this works too.


    ghoush
    Participant

    @ghoush

    Yep, I did that. Nice. Thanks for posting that fix. I thought I had edited that out.

    I can’t edit my earlier posts it seems, they are too old, could a mod maybe make that fix for us?


    ghoush
    Participant

    @ghoush

    Are you getting any error messages in your error logs? This code, unmodified, is working fine for me on 4.2.4.


    ghoush
    Participant

    @ghoush

    Just for people who don’t notice it. The forum id is in two places now, so replace both 691’s with your own forum id.


    ghoush
    Participant

    @ghoush

    An update:

    Here is the fixed up code, all working now. This version creates a meta value for the post and checks that next time it gets published. No more duplicates if something goes published->draft/pending->published again.

    
    function gh_post_published_create_topic( $ID, $post ) {
        $checkduplicate = get_post_meta( $ID, 'gh_topic_created',true);
        if ( empty( $checkduplicate ) ) {
            $author = $post->post_author;
            $name = get_the_author_meta( 'display_name', $author );
            $title = $post->post_title;
            $permalink = get_permalink( $ID );
            $excerpt = $post->post_excerpt;
            $subject = sprintf( '%s: %s', $name, $title );
            $message = sprintf ('[b]%s[/b]' . "\n" . 'By %s' . "\n\n" . '[i]%s[/i]' . "\n\n" . 'View: %s' . "\n\n", $title, $name, $excerpt, $permalink );
            $tags = wp_get_post_tags( $ID, array( 'fields' => 'names' ) );
    
            $new_post = array(
                'post_title'    => $subject,
                'post_content'  => $message,
                'post_parent' => 691,
                'post_status'   => 'publish',
                'post_type' => 'topic'
            );
            $topic_meta = array(
                'forum_id'       => $new_post['post_parent']
            );
            $topic_id = bbp_insert_topic($new_post, $topic_meta);
            if ( !empty( $topic_id ) ) {
                add_post_meta($ID, 'gh_topic_created', 'true', true);
                $term_taxonomy_ids = wp_set_object_terms( $topic_id, $tags, 'topic-tag' );
                bbp_update_forum(array('forum_id' => 691));
            }
        }
    }
    add_action( 'publish_post', 'post_published_create_topic', 10, 2 );
    

    ghoush
    Participant

    @ghoush

    Thanks for all that info Stephen!

    Is there any reason not to use the solution of just wrapping that argument in an array()? It does seem to solve the problem without having to remove functionality from the News SEO plugin.


    ghoush
    Participant

    @ghoush

    It was https://thedomain.com/ for wordpress and bbpress was standard, so https://thedomain.com/forums/

    For the path, it was standard for WP Engine:

    /nas/wp/www/cluster-1234/thedomain/

    The log was just getting spammed with that error until I added that array(). But it wasn’t the big problem, so I wouldn’t have looked or noticed it unless I was having some other unrelated issue.


    ghoush
    Participant

    @ghoush

    Nope, its on WP Engine. I went to look through the logs because I was having the capabilities problem. I couldn’t access any of the wp-admin bbpress screens without permissions errors. I used User Role Editor, and hit reset to fix that.

    Then looking through the logs the were just filled with the same error from the same line as this person who started this thread. Changed the path to HIDDEN here:

    Warning: in_array() expects parameter 2 to be array, null given in HIDDEN\wp-content\plugins\bbpress\includes\common\functions.php on line 1446

    Going into functions.php and changing the second parameter to be wrapped in an array() call fixes it.


    ghoush
    Participant

    @ghoush

    Just found this thread. Getting the error and can’t identify why. Disabling plugins didn’t help.

    Editing line 1446 and adding the array() call around the 2nd argument works fine and solves the problem. Is there any reason this is not done in the main code?

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