2011-11-22 48 views
0

我需要創建一個wordpress插件來將wordpress連接到中央登錄。但是我想要的只是用戶能夠發佈帶有姓名和電子郵件的評論。我不認爲我需要創建一個真正的登錄到WordPress,因爲用戶不應該能夠寫文章或做管理員的東西。我希望他只發表評論。創建用於外部登錄的wp插件=>發表評論

我搜索documentation,但找不到任何評論操作。

如何更改評論表單的html?

+0

在wp-comments-post.php中,我找到了操作'pre_comment_on_post'... – PiTheNumber

+0

pre_comment_on_post允許設置$ _POST ['author']和$ _POST ['email']。但是,我如何刪除表單域? – PiTheNumber

回答

0

也許不是很好,但它的工作原理...

填寫評論作者和電子郵件從存儲在會議中心登陸:從模板

function portal_user_comment() 
{ 
    $_POST['author'] = $_SESSION['portal']['name']; 
    $_POST['email'] = $_SESSION['portal']['email']; 
} 
add_action('pre_comment_on_post', 'portal_user_comment'); 

編輯的comments.php。尋找:

<input type="text" name="author" id="author" value="<?php $comment_author; ?>" ...> 
<input type="text" name="email" id="email" value="<?php $comment_author_email; ?>" ...> 

設置這兩個字段disabled="true"並用會話中的作者和電子郵件替換值。