Skip to:
Content
Pages
Categories
Search
Top
Bottom

Import single post and its comments

  • @jnomell

    Participant

    Hi, I have a somewhat unusual question. On my site, I have a specific post with 78 comments. Now that I’ve set up bbPress, I’d like to move the entire discussion—including the post and all comments—into a forum as a topic with replies.

    I haven’t found a ready-made way to do this. Using WP-CLI, I exported all 78 comments to a CSV file in the following format:

    “author_id”,”date_time”,”comment_text”

    I then tried creating a shell script that uses tail on the file, processes it with sed and cut to separate the columns, and then loops through an import with wp cli post create using post_type=reply and post_parent set to the main post (which I can easily create manually).

    But with my very basic knowledge, I haven’t been able to get it to work, so I’m giving up trying on my own. 🙂

    I only want to do this operation for this specific post, and maybe one more with 12 comments. It would be wonderful to have it moved as a topic in the bbPress forum.

    Does anyone happen to have a ready solution, or a bit of time to help me out? 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • @robin-w

    Moderator

    Ok, I am just a volunteer who helps out here, I am not a bbpress author, but I have written a number of bbpress related plugins.

    I also took over a defunct plugin called

    Post Comments as bbPress Topics

    I did not write this, I just did enough coding to get it working again.

    if you are code savvy, then function build_topic on line 485 of index.php should give you some code that you could maybe use in a plugin or use the code snippets plugin.

    otherwise if you only have a few posts from which you want 2, you could enable it convert, disable it and then delete the topics (posts) you don’t want.

    @jnomell

    Participant

    Thanks, Robin — much appreciated.

    Unfortunately, no, I’m not comfortable with code, and definitely not at that level.

    With the plugin you’re suggesting: am I correct in understanding that it does not import existing comments from the original post as replies in bbPress? What I would really like is to move all 78 comments over as replies in the bbPress topic, and ideally be able to delete the original post entirely afterwards.

    I’ve already created the topic itself manually in the correct forum, preserving the original text, date, and author. The only remaining (small 🙂) problem is the replies. And since those 78 comments contain a lot of valuable content, it wouldn’t feel right to start over from scratch in the forum.

    @robin-w

    Moderator

    ok if you can wait a day or 2, then I’ll write a small plugin that will do that, most of the code already exists.

    @jnomell

    Participant

    Thanks, Robin — that would be absolutely fantastic!

    With a smooth and simple solution like that, I could even consider importing 3–4 more posts that originally were discussion posts and would fit much better in the forum. But no larger volumes than that.

    I don’t know exactly how you’re planning to solve it, but if possible, it would be great to keep the original post and its comments intact until everything is confirmed to be working. If it’s easier to convert the existing content directly, that’s perfectly fine as well.

    In our system, users also have the option to delete their own accounts if they wish. I assume we therefore need to take into account that some users who commented may no longer have a valid user ID. In that case, I guess a fallback user is needed? I do have such a user in my system called “Deleted User,” whose user ID could be used if necessary.

    I’m also not entirely sure how bbPress handles topics and replies when the original user accounts are deleted — I haven’t had a chance to test that yet. 🙂

    Many thanks for your help. I really don’t have the required level of knowledge for this, so it’s very much appreciated. 🙂

    @robin-w

    Moderator

    quick response, I’m a UK farmer, so out a lot of the daytime !

    As a ‘quick and dirty’ solution you would need to create the topic

    Then in a new item I’ll add in the dashboard enter the post ID and the Topic ID

    This will then create a new reply.

    It will keep the existing comments.

    from memory bbpress uses ‘anonymous’ for any user that no longer exists, but if you create a ‘deleted user’ I might be able to add that to the code

    @jnomell

    Participant

    Topics already created with correct text, date and author so that’s fine.

    Anonymous as name for users that no longer exists is perfectly fine.

    So if I understand correctly, I would need to provide the ID of the original post and the ID of the new topic in the forum, and your plugin will “clone” each individual comment into a reply in the topic with the correct author and date? That sounds absolutely fantastic! 🙂

    @robin-w

    Moderator

    yep – that is what I am planning – be back when I’ve done it

    @robin-w

    Moderator

    Plugin created – go to

    Create replies from post comments

    and follow the instructions

    any issues let me know 🙂

    @jnomell

    Participant

    Hi Robin. I’ve now run the plugin with great success — no issues at all. I’m currently double-checking everything to make sure nothing went wrong, but so far it looks perfect. 🙂

    So my warmest thanks! I would never have managed to solve this on my own, despite my best attempts. 🙂

    @robin-w

    Moderator

    Great, glad to have helped 🙂

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