我想让任何访问者(非用户)都可以从WP前端创建自定义帖子,然后在电子邮件中获取密码,如果提供了正确的密码,他/她可以编辑帖子。
现在我只关注功能部分。是否有本地WP解决方案CPT 可编辑发布给可以输入特定帖子所需密码的非用户?
I would like to avoid generating extra number of Users for this feature, if possible.
*:默认情况下,创建的帖子将分配给管理员。感谢您的任何选择!
我想让任何访问者(非用户)都可以从WP前端创建自定义帖子,然后在电子邮件中获取密码,如果提供了正确的密码,他/她可以编辑帖子。
现在我只关注功能部分。是否有本地WP解决方案CPT 可编辑发布给可以输入特定帖子所需密码的非用户?
I would like to avoid generating extra number of Users for this feature, if possible.
*:默认情况下,创建的帖子将分配给管理员。感谢您的任何选择!
我建议有一个通用的表格,可以由公众在前端完成。表单的提交将生成帖子,在其元数据(密码)中保存一个随机字符串,并发送一封包含以下链接的电子邮件/?p=PAGEID&post_id=THE_POST_ID&pw=THE_PASSWORD
. POST\\u ID和\\u PASSWORD是来自生成的帖子的值,PAGEID是您创建的一个页面,其中包含用于处理编辑的快捷码。不要太过详细,但您的短代码如下所示:
add_shortcode(\'viktor_edit_post\', function() { // Sanitize $_REQUEST[\'post_id\'] = absint($_REQUEST[\'post_id\']); // Validate if(empty($_REQUEST[\'post_id\']) || get_post_status($_REQUEST[\'post_id\']) === FALSE || get_post_meta($_REQUEST[\'post_id\'], \'pw\', TRUE) !== $_REQUEST[\'pw\'] ) { // I would suggest echoing the public form here and handling its submission // here as well. I think it would be preferable as you need not hard-code // the PAGEID because this shortcode sits on that page. You could get it by way // of the global $page (as done below). return; } // If edit submission, update. if(wp_verify_nonce(\'viktor_nonce_\'.$_REQUEST[\'post_id\'], \'viktor_check\') && isset($_REQUEST[\'new_post_content\']) ) { wp_update_post(array( \'ID\' => $_REQUEST[\'post_id\'], \'post_content\' => sanitize_textarea_field($_REQUEST[\'new_post_content\']); )); } // Display edit form global $post; ?><form action=\'/?p=<?= $post->ID ?>\' method=\'POST\'> <?php wp_nonce_field(\'viktor_check\', \'viktor_nonce_\'.$_REQUEST[\'post_id\'], FALSE); ?> <input type=\'hidden\' name=\'post_id\' value=\'<?= $_REQUEST[\'post_id\'] ?>\'> <input type=\'hidden\' name=\'pw\' value=\'<?= $_REQUEST[\'pw\'] ?>\'> <p><?= sprintf( __(\'Please make changes as you see fit to %s.\'), get_the_title($_REQUEST[\'post_id\']), ) ?></p> <textarea name="new_post_content"><?= get_the_content(NULL, FALSE, $_REQUEST[\'post_id\']) ?></textarea> <?php submit_button(\'Save\'); ?> </form><?php });这里的交易是,你不能在控制你网站用户的功能上胡闹。由于您还想与非用户打交道,我认为一个简单的短代码插件是最好的选择。
我为一个拥有30000多个帖子的站点管理服务器。我尝试将站点从WP 4.9.9更新为当前的WP 5.0.2。更新似乎工作正常,但后端变得非常慢,而前端保持正常工作。更新后mytop 显示多个ALTER TABLE wp_posts ... post_password ... 正在运行的查询,以及在顶部为ALTER TABLE执行的复制操作,该操作占用了大部分数据库时间。我试着让它运行一整天,但它没有完成,而且我负担不起后端更长的停机时间,所以我已经从备份中恢复了整个安装,现在我又回到了WP 4.9.9。我