如果发布帖子,还可以自定义帖子类型、钩子get form status和post\\u type-{$new_status}_{$post->post_type}
- 处于活动状态,您可以使用此挂钩发送邮件。作为发布音乐的示例:add_action(\'publish_music\', \'fb_my_function\');
您还可以在邮件中发送修订,修订只是其他帖子类型,可以从数据库获取并添加到邮件的消息中。也许你可以在my last plugin, 发送邮件征求意见和帖子。
自定义post类型“归档”的简单示例
public $post_type_1 = \'archiv\';
add_action( \'publish_\' . $this -> post_type_1, array( $this, \'fb_my_function\') );
public function fb_my_function( $post_id = FALSE ) {
if ( $post_id ) {
// get data from current post
$post_data = get_post( $post_id );
//var_dump($post_data);exit; <-- see this for all content or use the id for get the revisons
// get mail from author
$user_mail = get_userdata( $post_data -> post_author );
// email addresses
$to = \'[email protected]\'
// email subject
$subject = get_option( \'blogname\' ) . \': \' . $post_data -> post_title;
// message content
$message = $post_data -> post_content . \' \' . PHP_EOL .
get_author_name( $post_data -> post_author ) . \' \' . PHP_EOL . .
get_permalink( $post_id );
// create header data
$headers = \'From: \' .
get_author_name( $post_data -> post_author ) .
\' (\' . get_option( \'blogname\' ) . \')\' .
\' <\' . $user_mail -> user_email . \'>\' .
PHP_EOL;
// send mail
wp_mail(
$to,
$subject,
$message,
$headers
);
}
return $post_id;
}