[Solved] How to automatically create a new topic in a forum?
How to automatically create a new topic in a forum, feeding title and content?
..and assign its ownership to a specific user
Please follow Sofy's answer in this support topic: https://wpforo.com/community/how-to-and-troubleshooting-2/is-there-any-way-to-add-new-posts-to-the-forum-programatically/#post-32888
Excellent, it works 🙂 Thanks a lot!
It turns out it worked when I visited the php file from the browser. When calling the script from code, it does not work.
I am assuming this may have to do with not properly signing in to wpForo, although I do not see any errors. What is the proper way to login to wpForo from code? I have tried adding this code in the script, which seems to signing to WordPress, but creating the topic still does not work when calling the script from code:
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
$user_login = 'admin';
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;