0

我有一个前端发布表格 - 我正在使用联系表格 7。

数据保存为帖子,状态为“待定”。

我想向用户发送一封电子邮件,其中将有激活链接以将状态从“待定”更改为“已发布”。用户未注册!我想保持这种状态。

我搜索了很多解决方案,但我只找到了向注册用户发送邮件的插件。

我在网上找到了一段代码,但不完整:

$unique = md5( $post->post_content );
add_post_meta( $post->ID, '_auto_publish', $unique );

// link to be sent
$link = get_permalink( $post->ID );
$link = add_query_arg(
array(
    'autopublish' => $unique,
    'pid'         => $post->ID
),
$link
);

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' );
}

这应该作为插件实现。你认为它可以工作吗?我想测试它,但无法将 print $link 输入到 CF7 自动回复邮件。

有没有更好的解决方案。请记住,提交表单的用户不是注册会员。

4

0 回答 0