首页 > 解决方案 > 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

标签: phpwordpress

解决方案


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.


推荐阅读