2016-11-30 4 views
0

OTPをユーザーに送信して確認しています。登録後にユーザーIDを取得するには?

私はwordpressを使用しています。デフォルトの登録フォームに携帯番号フィールドを作成しました。ユーザーが登録フォームを送信すると、アルゴリズムで生成したotpを受信し、smsを送信するためにsms APIを使用しました。

登録フォームを送信した後、彼はそのページの1ページにリダイレクトされます。私は姓、名字などの登録ユーザーの詳細を取得します。

そのユーザーのotpを確認できるようにします。

その他のことは、OTP確認後に初めてユーザーを登録する方法です。

+0

が有用である可能性があるhttps://developer.wordpress.org/reference/functions/get_user_by / – hisener

答えて

0

登録が成功した直後にuser_registerフックが発生します。

add_action('user_register', 'my_theme_registration_do_stuff', 10, 1); 

function my_theme_registration_do_stuff($user_id) { 

    // the only native way in WP to 'deactivate' a user is to set the role to 'none'. Read up on the implications of this and decide if this will suffice. If not, then you'll need to create some sort of user_meta to use for active/inactive user 

    $u = new WP_User($user_id); 
    // Remove role 
    $u->remove_role('subscriber'); //or whatever your site's default role is 

} 

これで、ユーザーは次のページに進みます。ユーザーがコードでSMSメッセージを取得したら

、彼/彼女はあなたのウェブサイト上のいくつかのフォームにコードを入力:

if(the code entered is correct){ 
     $user = new WP_User(get_current_user_id()); 
     $user->add_role('subscriber'); 
    } 
関連する問題