创建帖子并将其设置为pending
, 为自动发布生成唯一标识符,例如:
$unique = md5( $post->post_content );
add_post_meta( $post->ID, \'_auto_publish\', $unique );
现在为电子邮件创建链接:
$link = get_permalink( $post->ID );
$link = add_query_arg(
array(
\'autopublish\' => $unique,
\'pid\' => $post->ID
),
$link
);
在电子邮件中将此链接发送到提交者的地址:
print "<$link>";
然后观察匹配情况
$_GET
收件人单击链接时的参数:
if ( isset ( $_GET[ \'autopublish\' ] )
and isset ( $_GET[ \'pid\' ] )
and is_numeric( $_GET[ \'pid\' ] )
and $post = get_post( $_GET[ \'pid\' ] )
and $_GET[ \'autopublish\' ] === get_post_meta( $post->ID, \'_auto_publish\', TRUE )
)
{
$post->post_status = \'publish\';
wp_update_post( $post );
delete_post_meta( $post->ID, \'_auto_publish\' );
}