i have created a file called testsave.php which is writing in the database of the wordpress like this
testsave.php was placed in /wp-includes now i need to use the user ID to be inserted with the data in the database
i have tried to place this code in the file and use $current_user->ID instead of '1' to get the user ID but that did not work
any idea of how to place the user id in the inserted data in the database?
Code:
$content1 = '<img class="alignnone wp-image-11" src="http://web.qp2qp.com/qp2qp2/'.$file.'.png" alt="" />';
$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','', '', '', '','$file','','','','http://www.sktcho.com/?p=$file','')";
testsave.php was placed in /wp-includes now i need to use the user ID to be inserted with the data in the database
i have tried to place this code in the file and use $current_user->ID instead of '1' to get the user ID but that did not work
Code:
$current_user = wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
any idea of how to place the user id in the inserted data in the database?