php - Wordpress remove user registration for custom implementation
问题描述
I am integrating a user verification feature into a plugin I am developing whereby a user must verify their email address by clicking a link sent to them.
It is based on code provided on Github
At the moment I create a 'temporary' user, then delete the user from the users table. Only after verification is the user added back into the users table.
Is there a way to disable the core user registration in Wordpress so that I don't have to delete the user, therefore it is never stored in the database until it is created by the verification code?
I am finding, quite naturally, the user IDs are skipping every one digit so that for example, a verified user has an id '1' then the next is '3'.
Thanks,
Leon
解决方案
The standar way to do that is through a field in the table users that is set to true for example whenever the user have validated his email via your link.
And with this field you control that if the field is not validated you dont let them sign in on you website. So in order to apply this you need to find the sections in your wordpress that control de sign in to put the restriction with this new field
I'm going to be more specific so you can remove the downvote...
Lets think for example that you have a field named email_verify which will just contain a 1 or a 0 if the email is already validated or not. Then you have another field for example session_token with a sha1 or random token that must be unique for the link that will validate the email when clicking on it.
You need to have a php function that catches when someone enters that link and you do it by extracting the sha1 from the link as an url parameter and searching in your table for whoever have that session_token, when you find a record with this session_token then you turn your email_verify value to 1 meaning the email is already verified and then you turn null the session_token field so the link expires.
推荐阅读
- flutter - 当我点击它时隐藏高程按钮阴影
- node.js - 如何查找名称是否在 node.js 的 mongodb 中?
- terraform - 如何将 API 令牌作为 Terraform 秘密资源提供给 GitLab Terraform 提供者?
- javascript - 如何生成一组图标名称以用作 Vuetify v-autocomplete 语句中的选项?
- scala - sbt migration from 0.13.0 to 1.3.0
- c++ - 当 vt == VT_NULL 不起作用时如何检查 NULL 变量值?
- python - 如何在python中使用类更新gui
- c# - 在 Visual Studio 2019 中对运行 ASP.NET 的公共 IP 地址进行调试
- java - 无法从Java中的其他类获取变量
- javascript - Highstock 图表中的多个 Y 轴具有相同的缩放比例