Dzień dobry
Próbuję dodać nowy produkt z poziomu kodu w wordpress woocommerce i rozpoczynam to tak
include_once($_SERVER['DOCUMENT_ROOT'].'/wp-includes/post.php');
$post_id = wp_insert_post( array(
'post_title' => 'Great new product',
'post_content' => 'Here is content of the post, so this is our great new products description',
'post_status' => 'publish',
'post_type' => "product",
) );
print_r($post_id);
Chciałbym najpierw sprawdzić czy utworzyło wpis ale kod nie wypisuje nic. Proszę o porady.
problemem jest błąd
Fatal error: Uncaught Error: Call to undefined function get_current_user_id() thrown in /var/www/vhosts/c7.go4host.pl/httpdocs/wp-includes/post.php on line 2897