Can't use the funct...
Clear all

Can't use the function WPF()->post->add($reply)

2 Posts
2 Users
0 Reactions
Posts: 1
Topic starter
New Member
Joined: 4 months ago

I having some troubles with WPF() function.

I want to migrate old forum with a old data base, I need to insert reply in specific topic for all data i need to migrate. i parse my data and as it was mentionnened on this post :

i try to use this after require_once:


if(function_exists('WPF')) {
        $reply = array(
                'userid'  => 3,
                'title'   => 'RE',
                'body'    => 'test 2',
                'topicid' => 39,
                'created' => new \DateTime()
    $wpf = WPF()->post->add($reply);

i have this result when i launch my script : 

Error: Call to a member function add() on null

WPF exist cause i test if function exist but the property post is null.

I think this method (init_classes) in wpforo.php has not been call in this script, i try to call it in constructor but there is somes trouble after :

private function init_classes() {
		do_action( 'wpforo_before_init_classes' );
		$this->activity = new Activity();
		$this->api      = new API();
		$this->feed     = new Feed();
		$this->form     = new Forms();
		$this->forum    = new Forums();
		$this->log      = new Logs();
		$this->postmeta = new PostMeta();
		$this->post     = new Posts();
		$this->seo      = new SEO();
		$this->topic    = new Topics();
		$this->reaction = new Reactions();
		$this->bookmark = new Bookmarks();
		$this->sbscrb   = new Subscriptions();
		if( wpforo_is_module_enabled( 'revisions' ) ) $this->revision = new Revisions();

		do_action( 'wpforo_after_init_classes' );

Any idea about my issue ?


1 Reply
Posts: 4490
Support Team
Joined: 6 years ago

You can't access it from the single .php file. You'll need to create a separate plugin. Utilize the wpforo_core_inited hook and then add your custom logic.