Hey, I need help making WordPress post to IP.Board 3 after its done publishing and such. I inserted the following code before return $post_ID;
into wp-includes/post.php.
<?php
/**
* Library to facilitate posting to the IP.Board 3 forums
*
* @author bfarber
* @version 1
* @since 3rd April, 2009
**/
/**
* Post
* Provides a wrapper class for posting new topics to the forums
*
* @author bfarber
*/
class Post
{
/**
* Path to the forums
*
* @access public
* @var string
*/
public $forumPath = "/my/path";
/**
* Forum ID for new posts
*
* @access public
* @var integer
*/
public $forumId = 27;
/**
* IPB Post Class
*
* @access private
* @var object Post Class
*/
private $_postClass;
/**
* Post details
*
* @access public
* @var array
*/
public $postData = array(
'member_id' => 2229,
);
/**
* Construct our object
*
* @access public
* @return void
*/
public function __construct( $forumPath='' )
{
/**
* Set forum path
*/
if( $forumPath )
{
$this->forumPath = $forumPath;
}
/**
* IPB stuff
*/
define( 'IPB_THIS_SCRIPT', 'public' );
chdir( $this->forumPath );
require_once( './initdata.php' );
}
/**
* Associate the user
*
* @access public
* @param array User data
* @return void
*/
public function associateUser( $user )
{
if( !$user['email'] )
{
return false;
}
/**
* IPB registry
*/
$ipbRegistry = ipsRegistry::instance();
/**
* Get and set user
*/
$IPBUser = IPSMember::load( $user['email'] );
if( $IPBUser['member_id'] )
{
$this->post['member_id'] = $IPBUser['member_id'];
$this->post['member'] = $IPBUser;
}
}
/**
* Post the topic..
*
* @access public
* @param array User data
* @return bool
*/
public function postTopic( $user = array() )
{
global $post_ID;
/**
* IPB registry
*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
$ipbRegistry = ipsRegistry::instance();
$ipbRegistry->init();
/**
* Associate user
*/
$this->associateUser( $user );
/**
* IPB forums class
*/
require_once( IPSLib::getAppDir( 'forums' ) . '/app_class_forums.php' );
$appClass = new app_class_forums( $ipbRegistry );
/**
* Get post class
*/
require_once( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPost.php' );
$this->_postClass = new classPost( $ipbRegistry );
/**
* Set some data
*/
$post = get_post($post_ID);
$title = $post->post_title;
$content = $post->post_content;
$this->_postClass->setIsPreview( false );
$this->_postClass->setForumData( $ipbRegistry->getClass('class_forums')->forum_by_id[ $this->forumId ] );
$this->_postClass->setForumID( $this->forumId );
$this->_postClass->setPostContent( $content );
$this->_postClass->setAuthor( $this->postData['member_id'] );
$this->_postClass->setPublished( true );
$this->_postClass->setSettings( array( 'enableSignature' => 1,
'enableEmoticons' => 1,
'post_htmlstatus' => 0,
'enableTracker' => 0 ) );
$this->_postClass->setTopicTitle( $title );
/**
* And post it...
*/
try
{
if ( $this->_postClass->addTopic() === FALSE )
{
return false;
}
}
catch( Exception $error )
{
print "Topic posting failed: " . $error->getMessage();
exit;
}
$this->topic = $this->_postClass->getTopicData();
$this->post = $this->_postClass->getPostData();
return true;
}
}
?>
I checked with the WordPress codex and the WordPress function I use in that code, get_post()
does indeed work. What doesn't work is the action this code is supposed to fulfill, when you try to publish from WordPress, it returns a blank page (but the post is still published to WordPress) and it doesn't post to IP.Board.
If anyone can help me with getting WordPress to post to IP.Board 3, even with another code, that would be great.
Thanks.