Skip to:

Populate forum_slug and topic_slug fields

  • Hi! I’m a brand new bbpress user, and looking forward to getting better acquainted with all of you. However I do have an immediate issue on which I could use some advice.

    I’ve made a conversion from vbulletin 3, via phpbb3, to bbpress 1.0.2. In the process, none of the slugs for the forums or topics fields were populated. Would any of you have a nice solution for that handy?

    I’ve put this in the Installation topic, because bbpress isn’t broke. I believe this is more likely an artifact from the conversion. Please feel free to correct me if I’m wrong.


    Dan White

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

  • kevinjohngallagher


    Good Morning Dan,

    It definately sounds like a conversion issue. It’s not one i’ve heard of before, but it shouldn’t be too hard to fix (though there is no existing pluign that I know of).

    Baiscally you’re going to need a Title to Slug function, then iterate through every forum & topic and update the database accordingly

    Basically, something like this:

    $sql = "SELECT * from $bbdb->topics WHERE topic_slug ='' LIMIT 100";
    $rows = $bbdb->get_rows($sql);

    foreach($rows as $row)
    $topic_slug = bb_sanitize_with_dashes($row['topic_title'],200);
    $sql = "UPDATE $bbdb->topics SET topic_slug='". $topic_slug ."' WHERE topic_id=". $row['topic_id'] ." LIMIT 1; ";

    So i’ve not tested this code at all, just guessing at it really.

    It should update 100 topics at one page load.

    (I do this incase i made a horrible mistake)

    Then do the same for bb_forum table.


    Thanks Kev, that’s a big help. I understand everything in that bit of code except the line

    “$topic_slug = bb_sanitize_with_dashes($row,200);”

    Would you care to enlighten me on how that would add dashes? I was thinking that I’d have to parse the topic_title field with regexp somehow (not great at regexp yet, just learning)then create the string. Is that what this represents?


    Dan White



    The function itself adds the dashes and removes the blacklisted characters (or maybe allows only whitelisted characters).

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