Notifications
Clear all

Script [Solved] Handling attachments in a custom forum import script - wpfa-## div ids?

2 Posts
2 Users
0 Reactions
139 Views
Posts: 1
Topic starter
(@petshwarkud)
New Member
Joined: 2 months ago

I'm writing a set of PHP command-line scripts to import some data from an old forum system (developed in-house in MS SharePoint), and I'm having trouble figuring out how to handle attachments.  My import scripts are not using WP or WPForo code as they run from the command line on the hosting computer and directly manipulate the WP and WPForo tables.  I've not entirely got the import procedures working, but I've gotten pretty far along.

Recently I started tackling attachments to posts.  Looking at some test posts with attachments, I've noticed that the attachment(s) are represented by a div in the post. Here's an example attachment div from my test system (note the "wpfa-25" id):

<div id="wpfa-25" class="wpforo-attached-file">
<a class="wpforo-default-attachment" href="//wpforo-test.local/wp-content/uploads/wpforo/default_attachments/1712254488-Schwenk_Peter-2018-009.jpg" target="_blank" title="Schwenk_Peter-2018-009.jpg">
<i class="fas fa-paperclip"></i>
&nbsp;Schwenk_Peter-2018-009.jpg</a>
</div>

Each div has an id with a value of "wpfa-##" where "##" is a positive integer.  I haven't been able to figure out where this integer comes from and what, if anything, it references.  There don't appear to be any references to the attachments in the database tables, so I'm wondering if they are there for styling purposes, and I also wonder if I can just generate my own unique integers since they don't seem to relate to anything in the data.  My hope is that the ids only have to be unique and start with "wpfa-", but I'm writing this post to get confirmation.

Uploading the actual attachment files to the appropriate folder isn't an issue, and giving the attachments unique names is easy.  I just want to make sure that I'm not mistreating the id in the attachment divs.

Any help would be greatly appreciated.

1 Reply
Sofy
Posts: 4416
 Sofy
Admin
(@sofy)
Support Team
Joined: 6 years ago

The "wpfa-##" is not required.

wpForo has the "Insert Forum Attachments to Media Library" option in the Dashboard > wpForo > Settings > Posting & Editor Settings admin page. This feature allows attachments to be inserted into the WordPress library, enabling easy management from the Dashboard.

If the option is enabled, the attachments will be inserted into the 'wp_posts' table with 'post_type' set to 'attachment'. Just like regular media files, and those IDs will be used.

However, if the option is disabled, the "wpfa-0" will be used.