Skip to:
Content
Pages
Categories
Search
Top
Bottom

Grabbing the tag_id or topic_id with add_action


  • benbeltran
    Member

    @benbeltran

    Hello bbpress community.

    I’m trying to write a plugin that checks certain actions and saves them to a “status feed” so they appear in a friendfeeed-ish manner.

    eg.

    User made a new post

    User started a topic

    User tagged a topic

    etc.

    bb_new_post and bb_new_topic return the post and topic id respectively so it’s easy to grab it… But I’m using add_action('bb_add_topic_tags', 'status_tags_update'); to check the tags. The thing is, it seems to break tagging.

    I checked bb_add_topic_tags and it returns tt_ids, which I assumed was an array of the inserted tag ids. But I’m probably wrong. I don’t understand very well what $tt_ids = $wp_taxonomy_object->set_object_terms( $topic->topic_id, $tags, 'bb_topic_tag', array( 'append' => true, 'user_id' => $user_id ) ); is supposed to do. So I don’t understand what’s being returned. I’m trying to get either the tag id, or preferably the topic id.

    Any of you plugin-savvy users have any idea/help?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Doing a quick var_dump of the passed argument, it’s just a string of the tags passed by the user (commas and all) and before checks are made to see if they’re existing tags. I think you’d want to use bb_tag_added which passes $tt_id, $user_id, $topic_id as each tag is added (if you register the action function as taking as many variables).


    benbeltran
    Member

    @benbeltran

    Yeah… apparently add_action('bb_tag_added', 'status_tags_update',100,3); won’t work. I don’t think the action is running. Which is odd.

    I’ll keep on looking, any new help is appreciated. And thanks for the tip.

    It’s not necessarily very obvious if it is run unless you get something to echo because it’s all hidden under AJAX

    <?php
    function status_tags_update( $a, $b, $c ) {

    var_dump($a);
    var_dump($b);
    var_dump($c);

    }

    add_action('bb_tag_added', 'status_tags_update',100,3);
    ?>

    I put that in my functions.php and it happily threw out some mangled HTML with the dumps underneath the tag list :)


    benbeltran
    Member

    @benbeltran

    Yeah. I mean, that’s why I think it’s odd. I tried to add some dummy text to the db and then to do what you just posted. But it didn’t work. Must check why. It’s really weird, since the other actions work properly.

    There might be a fatal database error, and database errors might hidden by default, $bbdb->suppress_errors( false ); will turn them on if they are. Obvious question is, does that work without any database interaction?


    benbeltran
    Member

    @benbeltran

    Nope. Doesn’t work With or without database interaction.

    Guh. Last stab at it, the action only runs on a valid tag being added (rather than just an attempt being made to add one). Beyond that though, who knows, I’m running 2.8.2 SVN so it’s always hard to tell what’s just me :)


    benbeltran
    Member

    @benbeltran

    Thanks. I’ll keep on trying. I’m not using wordpress though, it’s a 100% custom system integrated with bbpress. I’m sure it’ll turn out to be something stupid from my part.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar