用戶ID我已經創建了一個名爲testsave.php文件,其在WordPress的數據庫寫入這樣得到在WordPress
$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置於/可溼性粉劑包括現在我需要使用用戶ID插入數據庫中的數據
我試圖將此代碼放在文件中,並使用$ current_user-> ID而不是'1'來獲取用戶ID,但沒有工作
$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 />';
有關如何將用戶標識放入數據庫中插入數據的任何想法?
我嘗試過了,我有這樣的:
請把你的代碼。 – user1078685