Reputation: 307
I am using a PHP file which creates new posts in the database of Wordpress using this line:
$sql = "INSERT INTO wp_njvt_posts (post_date,post_date_gmt,post_author, post_content, post_title, post_excerpt, post_password, post_name, to_ping, pinged, post_content_filtered, guid, post_mime_type) VALUES (NOW(),NOW(),'1','$content1', '', '', '','$file','','','','http://www.sktcho.com/?p=$file','')";
Now I need to get the user ID from the Wordpress website and use it in this file to enable the user to create a new post from his account instead of user ID '1' which I am currently using.
Upvotes: 0
Views: 1538
Reputation: 699
To build on what Dennis answered:
You can use the wp_get_current_user()
on the wordpress site then build a function to pass the id to the other website, not really secure but could do it through a url variable for simplicity. Then just need to take the variable from the URL on the new site and create a cookie with the ID. I am in no way saying this is the best method or the proper way but would do what you need it to do, as long as all you need is the user id and don't need the active session.
Upvotes: 1
Reputation: 494
You are looking for wp_get_current_user()
which returns the user which has the ID
property. A look into the docs would help.
Upvotes: 1