我在函数中添加了以下代码。php在允许用户填写表单之前验证用户是否已登录:
function my_members_only_shortcode($atts, $content = null)
{
if (is_user_logged_in()) {
$content = do_shortcode($content);
} else {
$content = \'This content is for members only, please log in or register first.\';
}
return $content;
}
add_shortcode(\'members_only\', \'my_members_only_shortcode\');
以上代码使我能够使用[members_only][iphorm id="1" name="Example form"][/members_only]
阻止用户在未登录时访问表单-但是,我希望[仅限Members\\u]功能/短代码显示指向wp登录的可单击超链接。php页面,用户可以在该时间点轻松登录和注册-或者,如果[仅成员]功能可以自动将小部件放置在未登录消息下的“未登录”区域中,我希望它是社交媒体登录小部件,我可以使用插件创建的短代码在帖子中调用它-[do\\u小部件“社交登录”]