Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
custom-topic
Moving comments to forum
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Jul 9, 2017 - 9:21 pm
sp_QuotePost Quote

Ok, this has taken me forever to get to...

A while back I copied all my articles that included comments over to the forum as forum posts. ( https://simple-press.com/suppo.....g-linking/ )

Now, I'd like to move the comments that are on those articles over to the forum, so I have posts and comments on the forum. 

I'm thinking I need to do something along these lines, but I'm not fluent enough in php/mysql to write it myself (probably could, but it would take me another three months!).

 --------------------------

grab row from wp_comments

//hold that info in array as a var

//pull out comment_post_ID as a var

from table wp_sflinks get forum_id and topic_id where post_id = comment_post_ID

//hold forum_id as a var

insert into wp_sfposts

post_id //needs to increment from previous existing
post_content // comment_content from wp_comments
post_date //comment_date from wp_comments
topic_id // topic_id from wp_sflinks
user_id //user_id from wp_comments
forum_id //forum_id from wp_sflinks
guest_name //comment_author from wp_comments
guest_email //
post_status //
post_pinned //
post_index //hmmm, need to increment from the previous with the same topic_id, maybe make this whole thing a while statement (while comment_post_ID loop through rows and increment this?)
post_edit //
poster_ip //
comment_id //
source //

 //need to put a limit on the script so it doesn't crash server trying to move 5000+ comments.

Is there anyone available to write this?  Not sure I have all the working parts in place, so it will have to be thought out to make sure.

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 10, 2017 - 7:48 am
sp_QuotePost Quote

You are OK up to the part where you want to create the new forum data - i.e, the post record. There is a little more to it than just writing to the one table.

i would suggest you take a look at the code file /simple-press/forum/library/sp-post.php. This sets everything up to create a new topic and/or post record. It goes through the major steps for you. If you check the data requirements you will be able to trace through the new post action.

This code obviously uses POST variables but it should be pretty straightforward to adapt it for, say, using an AJAX call for each record. That gets you over the timeout issue as well of course. The main thing is to fill the required values and then pass control over to the post class.

Could we do it? I have to say straight off that certainly not very quickly or soon...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Jul 13, 2017 - 8:45 am
sp_QuotePost Quote

Thank you... are there any freelancers that know SP well enough to do this that you would recommend?

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 13, 2017 - 10:08 am
sp_QuotePost Quote

I'm sorry - but to be perfectly honest I do not know anyone. We always hoped that one or two people might materialise and we do know that some people do perform some customisation work on their own site, but we have never been asked to keep anyones name for such queries.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Jul 17, 2017 - 9:25 am
sp_QuotePost Quote

I'm looking through simple-press/forum/library/sp-post.php but don't see what data I need to put into what tables. I see the validation checks, and then the part where it says it is saving to the database, but not what data is being added to what tables....

Still studying it - 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 17, 2017 - 11:25 am
sp_QuotePost Quote

You would need to look at the sp-api-class-post.php file (in sp-api folder) - at the top are the variable declarations that make up the 'newpost' array.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 17, 2017 - 11:31 am
sp_QuotePost Quote

Actually forget that - I am being dumb.

Open up the file /librtary/sp-linking-comments.php.

Find the function sp_create_post_from_comment().

That function does what you want to do - saves a comment as a forum post. You wont be able to call it as is but you should be able to rewrite for your requirements.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Jul 19, 2017 - 11:18 am
sp_QuotePost Quote

That function almost looks like if I made an edit in a comment it should add that comment as a post to the forum if it's linked. 

I edited a comment (from the wp admin) and it didn't do anything though.... 

On a larger scale, I was wondering if I could 'trick' the script into thinking a number of comments were edited so I could enter a bunch at a time.... just brainstorming since I don't quite understand the code enough to really know what it's doing. I'm picking through it though and may be able to figure it out - 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
Jul 19, 2017 - 3:07 pm
sp_QuotePost Quote

Opps, I was looking at the function that followed the one you mentioned when I wrote that - sorry, don't think that applies.

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 19, 2017 - 10:32 pm
sp_QuotePost Quote

you dont think the function Andy provided will work??

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616