Support Forum
Happy to help too. Hope to try the basics soon. Just bad timing with Andy on vacation and me moving this weekend.
Visit Cruise Talk Central and Mr Papa's World
Moving, what fun! I've been doing a lot of that over the last 6 months, our house was totaled in hurricane matthew and we are rebuilding. Both moving ourselves and helping friends. If I was in your area I'd be happy to come help there too 🙂
Looking at the code, but not really familiar with hooks and all, it seems like I should be able to temporarily hack sp-linking-support.php and do something like this to add my old posts in with the original publication dates:
Didn't work though...
////////////////////////////////////
function sp_do_linking_update_blog_post($newpost) {
global $wpdb;
$ID = sp_esc_int($newpost['blogpostid']);
$postcontent = $newpost['postcontent']; # it comes here already filtered
spdb_query("UPDATE ".$wpdb->prefix."posts SET post_content = '$postcontent'
//post_date = the_date() //didn't work
//post_date = '2016-05-20 11:05:19' //for testing, didn't work
WHERE ID = $ID"); }
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
well, that couldnt work, because its updating a linked forum topic... in your case, the topic doesnt exist yet.. you would want the routine where the topic is created... that would be sp_publish_blog_link()...
then in that routine, use the $post->post_date or $post->post_date_gmt to get the blog post date... and then try setting $p->newpost['post_date'] equal to that blog post date... if your timezone matches the server timezone, think the dates will be fine... but have not tried this...
Visit Cruise Talk Central and Mr Papa's World
Sorry, it's over my head...
Do you mean something like this?
---------
$p->newpost['forumid'] = $forumid;
$p->newpost['forumslug'] = $forumslug;
$p->newpost['topicname'] = sp_filter_title_save($post->post_title, SFTOPICS, 'topic_name');
//added
$p->newpost['post_date'] = $post->post_date;
---------
That didn't seem to make it into the sql, still uses current date...
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
will try to look further tonight (but moving to new house so may be hard)... I think you want to do the setting of the date later... in its own query.. or just before the saveData call for the post class...
Visit Cruise Talk Central and Mr Papa's World
Well, I can add an sql statement under the SaveData part to give it a date:
$sql = "UPDATE wp_sfposts SET post_date = ".$p->newpost['post_date']." WHERE topic_id = ".$p->newpost['topicid'];
But I'm having trouble getting the $p->newpost['post_date'] value. I can hard code a date in there and it works, but I haven't been able to figure out how to get that date in the code,
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
sorry, not sure I follow... seems you are saying that line of code works, but you cant get the $p->newpost[‘post_date’] value??? which seems to conflict with it working... can you explain what code you have that is not working?
Visit Cruise Talk Central and Mr Papa's World
Sorry I was unclear - 🙂
If I do this:
$sql = “UPDATE wp_sfposts SET post_date = “2016-06-26 11:02:4” WHERE topic_id = “.$p->newpost[‘topicid’];
I get that date into the database, so I know the sql works.
I think I probably need to put this (or something else?):
$p->newpost[‘post_date’] = $post->post_date;
in before that, but I haven't figured out what and where, so that the date that is on the original post is used.
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
ah, I understand... you cannot reference $post in that routine as it doesnt exist in the scope... I had intended for you to put the code in the blog linking plugin itself AFTER the call to saveData...
looking at this a bit more, might need a bit more magic too...
before:
$p->saveData();
add
add_action('sph_new_post', 'my_linking_code'); function my_linking_code($newpost) { global $spVars; $spVars['linkedpost'] = $newpost['postid']; }
and then after this:
$sql = "UPDATE ".SFTOPICS." SET blog_post_id = ".$post->ID." WHERE topic_id = ".$p->newpost['topicid']; spdb_query($sql);
add:
$sql = "UPDATE ".SFPOSTS." SET post_date = ".$post->post_date." WHERE post_id = ".$sfVars['linkedpost']; spdb_query($sql);
still untested... 🙁
Visit Cruise Talk Central and Mr Papa's World
Alas, still getting today's date.
Sorry it took me a bit to get back to you on this.
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/