등록 된 사용자가 Wordpress 블로그에 게시 할 수있는 테마로 작업하면서 양식 (제목, 카테고리, 항목)을 만들었습니다.
질문은 "새 답변이 게시 될 때 알림"확인란을 어떻게 추가 할 수 있습니까? 플러그인이 아니라 함수가 필요합니다. 여기
질문 게시를 처리하는 기능입니다 :기능 post_new_question ($ QUESTION_TITLE, $ question_content, $ question_category) {
$question_title_stripped = strip_tags($question_title);
$question_content_stripped = strip_tags($question_content);
$user = wp_get_current_user();
global $wpdb;
$gather_questions = "SELECT * FROM wp_posts WHERE post_author = '" . $user->ID . "'";
$user_questions = $wpdb->get_results($gather_questions);
if (isEmptyString($question_title_stripped)) return new WP_Error('no_title_entered', 'Enter a title for your quesion');
if (isEmptyString($question_content_stripped)) return new WP_Error('no_content', 'Enter a breif description for your quesion');
foreach ($user_questions as $user_question) {
if ($user_question->post_author == $user->ID) {
if ($user_question->post_title == $question_title_stripped) {
return new WP_Error('duplicate_user_question', 'You have already asked this exact question.');
} else {}
} else {}
}
$question_author = $user->ID;
$post = array(
'ID' => '',
'post_author' => $question_author,
'post_category' => array($question_category),
'post_content' => $question_content_stripped,
'post_title' => $question_title_stripped,
'post_status' => 'publish'
);
$question_id = wp_insert_post($post); }
PS : wp_email 기능의 사용법은 좋은 것입니다.
감사합니다. 그러나 사용자가 알림을 받고 싶는지 여부를 확인했는지 확인하는 방법은 무엇입니까? 특정 게시물에 대한 새로운 답변은 어디에서 찾으십니까? –
알림을 받으려면 데이터베이스에서 게시물 메타 또는 사용자 지정 테이블을 사용하여 해당 환경 설정을 저장해야합니다. 주석 시스템을 사용하고 주석을 응답으로 사용할 수 있으며, 사용자가 전자 메일을 수신할지 여부를 확인하고 전자 메일을 보낸 경우 새 기능이 게시 될 때 기능을 실행하도록 작업 시스템을 묶을 수 있습니다. – dirk
실제로 답변과 같은 역할을합니다. 새 테이블 wp_notify를 만들고 user_id 및 post_id를 저장합니다 (통지 받고 싶다면). 하지만 새로운 답변이 해당 항목에 게시되어 있는지 확인하는 방법에 대한 예가 필요합니다. 감사. –