wordpress表单调用_如何将WordPress表单限制为仅登录用户

wordpress表单调用

Are you looking for an easy way to restrict your WordPress form submissions to logged-in users only?

您是否正在寻找一种简单的方法来将WordPress表单提交限制为仅登录用户?

If you have a membership site, online store, or another type of website that has registered users, then you may want to restrict certain forms access to only logged in users.

如果您拥有会员网站在线商店或具有注册用户的其他类型的网站,则您可能希望将某些表单访问权限限制为仅登录用户。

In this article, we will show you how to restrict your WordPress forms access so only logged in users can fill out and submit them.

在本文中,我们将向您展示如何限制WordPress表单访问,以便只有登录的用户才能填写和提交它们。

Restrict Form Access in WordPress
什么时候以及为什么需要限制对WordPress表单的访问? (When and Why You Need to Restrict Access for WordPress Forms?)

There could be a number of scenarios when you would need to restrict access to certain WordPress forms to logged-in users only.

当您需要将对某些WordPress表单的访问权限限制为仅登录用户时,可能会有多种情况。

For example:

例如:

  • You may be hosting a private members event, and you only want registered users on your site to RSVP.

    您可能正在主持一个私人成员活动,并且只希望您站点上的注册用户能够接受RSVP。
  • You may restrict access to support for members only, and by restricting it to logged-in users only, you can dynamically populate certain information from their profile.

    您可以将访问权限限制为仅对成员的支持,并且通过将其限制为仅登录用户,可以从其个人资料中动态填充某些信息。
  • survey or 调查poll, and you want to restrict access to your internal team only.民意调查 ,并且只想限制对内部团队的访问。
  • customer NPS survey that you only want to be submitted by logged-in users only.客户NPS调查 ,仅希望由登录用户提交。
  • You might have a special prize claim form that you want to be accessed by only certain logged-in users.

    您可能有一个特殊的奖金申请表,只希望某些登录用户访问。

These are just some examples, but there could be literally hundreds of other use cases where you want to restrict form access to registered users only.

这些只是一些示例,但是实际上您可能想将其他数百种用例限制为仅对注册用户进行表单访问。

With that said, let’s take a look how to restrict your WordPress form access to logged-in users only.

如此说来,让我们看一下如何将WordPress表单访问限制为仅登录用户。

影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

方法1:使用WPForms Form Locker插件限制表单访问 (Method 1: Restrict Form Access with WPForms Form Locker Addon)

This method is easiest and most powerful, so we recommend it for all beginner users. We will use the WPForms plugin and their Form Locker addon to completely lock down WordPress form access.

这种方法最简单,最强大,因此我们建议所有初学者使用。 我们将使用WPForms插件及其Form Locker插件来完全锁定WordPress表单访问。

WPForms is the best WordPress form plugin used by over 2 million websites. It was created by WPBeginner’s founder, Syed Balkhi, to have all the features we needed for running our business.

WPForms是超过200万个网站使用的最好的WordPress表单插件 。 它是由WPBeginner的创始人Syed Balkhi创建的,具有我们运营业务所需的所有功能。

The first thing you need to do is install and activate the WPForms plugin. For more details, see this step by step guide on how to install a plugin in WordPress.

您需要做的第一件事是安装并激活WPForms插件。 有关更多详细信息,请参阅有关如何在WordPress中安装插件的分步指南。

Upon activation, you need to enter your license key and then add over to the WPForms » Addons page to install the Form Locker Addon.

激活后,您需要输入许可证密钥,然后添加到WPForms»Addons页面以安装Form Locker Addon。

WPForms Form Locker Addon

Now you’re ready to create a new form that has restricted access for logged-in users.

现在,您可以创建一个新表单,该表单对登录用户具有受限的访问权限。

To do this, go ahead and create a new form by going to WPForms » Add New. This will open the WPForms form builder where you will be presented with the option to either choose a form template or start with a blank one.

为此,请转到WPForms»Add New来创建一个新表单。 这将打开WPForms表单构建器,在该构建器中将为您提供选择表单模板或从空白模板开始的选项。

WPForms drag & drop form builder is extremely easy to use, so you can add or remove fields and customize the form to your liking.

WPForms拖放表单构建器非常易于使用,因此您可以根据自己的喜好添加或删除字段并自定义表单。

WPForms Form Builder

Once you have added all the necessary fields, you need to go to the Settings Tab and click on Form Locker.

添加所有必要字段后,需要转到“设置”选项卡,然后单击“表单锁”。

WPForms Form Locker Settings

On this tab, you will see the option to enable password protection for your WordPress forms, set total entry limits, enable form scheduling, and enable restricting entries to logged-in users only.

在此选项卡上,您将看到以下选项:为WordPress表单启用密码保护,设置总条目限制,启用表单计划以及仅将登录条目限制为登录用户。

Form Locker Logged in User Only

Once you check the box, you will see a new Message field where you will need to draft a message that will appear to all users who are not logged in to your site.

选中该框后,您将看到一个新的“消息”字段,您需要在其中草拟一条消息,该消息将显示给所有未登录您的网站的用户。

WPForms Form Locker Restrict Access Message

Once done, you can tweak other form settings that you might need and then click the Save button.

完成后,您可以调整可能需要的其他表单设置,然后单击“保存”按钮。

Now you can embed this form on any WordPress post or page on your site by using the WPForms shortcode in the Classic Editor or by using the WPForms block in the Gutenberg editor.

现在,您可以使用经典编辑器中的WPForms简码或使用Gutenberg编辑器中的WPForms块将此表单嵌入到您网站上的任何WordPress帖子或页面上。

Simply go to Post or Pages, and then click on the Plus icon to select a block. Next, type WPForms in the block search.

只需转到发布或页面,然后单击加号图标以选择一个块。 接下来,在块搜索中键入WPForms。

Add WPForms block to WordPress post or page

Once the WPForms block is added, select your form to embed and you’re done. Congratulations, you have successfully created a WordPress form that’s restricted to logged-in users only.

添加WPForms块后,选择要嵌入的表单即可完成。 恭喜,您已经成功创建了WordPress表单,仅限于登录用户。

方法2:使用受密码保护的页面或专用页面限制表单访问 (Method 2: Restrict Form Access with Password Protected or Private Pages)

Another way to restrict form access in WordPress is by using the default WordPress visibility settings. You can use this method with the free version of WPForms or any other contact form plugin.

限制WordPress中表单访问的另一种方法是使用默认的WordPress可见性设置。 您可以将此方法与WPForms免费版本或任何其他联系表单插件一起使用。

Simply create a Page or Post where you want to embed the form. After that click on the Visibility settings on the right panel.

只需在要嵌入表单的位置创建页面或帖子。 之后,单击右侧面板上的“可见性”设置。

WordPress Page Visibility Settings

You have the option to either make the whole page private or make the whole page password protected.

您可以选择将整个页面设为私有,也可以将整个页面设置为密码保护。

Private pages can only be seen by the Administrators and Editor level users on your website.

私有页面只能由您网站上的管理员和编辑者级别的用户看到。

If you set a password for the page, then you will have to share that password with everyone who you want to give access to.

如果为页面设置密码,则必须与要授予访问权限的所有人共享该密码。

While this method works, there are several downsides to it.

尽管此方法有效,但它有几个缺点。

First, the entire page is hidden not just the forms area. You lack the finer controls, and there’s no way for you to see which logged-in user submitted the form (if you’re using the password protected setting).

首先,整个页面被隐藏,而不仅仅是表单区域。 您缺少更好的控件,因此您无法查看哪个登录用户提交了表单(如果您使用的是密码保护设置)。

方法3:使用高级成员资格插件来限制表单访问 (Method 3: Use Advanced Membership Plugins to Restrict Form Access)

If you’re using an advanced WordPress membership plugin like MemberPress, then it comes with a lot of access control features built-in.

如果您使用的是诸如MemberPress之类的高级WordPress成员资格插件 ,那么它将内置许多访问控制功能。

You can simply go to MemberPress » Rules to create a new permissions rule.

您只需转到MemberPress »规则即可创建新的权限规则。

Add new rules in MemberPress

The rule edit page allows you to select different conditions and associate them to a membership plan.

规则编辑页面允许您选择不同的条件,并将其与会员计划关联。

For example, you can select all content that matches a particular tag or category to be available only to members with the silver subscription plan.

例如,您可以选择与特定标签或类别匹配的所有内容,仅对具有白银订阅计划的成员可用。

Add a rules set to MemberPress

You can also create more specific rules. For example, a single post or page, child pages, or a specific URL.

您还可以创建更具体的规则。 例如,单个帖子或页面,子页面或特定的URL。

Once you have set the rules, you can use it in combination with any WordPress contact form plugin to restrict form access to logged-in users only.

设置规则后,您可以将其与任何WordPress联系人表单插件结合使用,以将表单访问权限限制为仅登录用户。

For more details, see our step by step guide on how to restrict content access in WordPress.

有关更多详细信息,请参阅有关如何限制WordPress中的内容访问的分步指南。

We hope this article helped you learn how to restrict your WordPress forms to logged-in users only. You may also want to see our list of best WordPress plugins for business websites.

我们希望本文能帮助您学习如何将WordPress表单限制为仅登录用户。 您可能还想查看我们用于商业网站的最佳WordPress插件列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-restrict-your-wordpress-forms-to-logged-in-users-only/

wordpress表单调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值