How Add phone numder field to registration form and verfiy with OTP

How Add phone number field to registration form and verify with SMS OTP
Please provide solution feature which is highly recommended for Middle east and India users

Unfortunately there’s no simple code snippet for adding this feature, but thanks for your feedback - we added this feature to the HivePress roadmap 2FA for logging in and other actions

Waiting…

I have configured third party plugin with firebase it is working fine. and i tried to integrate with the following snippet to override current sign in form.
but the result is both forms are appearing together.

how to hide the old form fields and button, pls help/

add_filter(
	'hivepress/v1/forms/user_login',
	function( $form ) {
		$form['header'] = do_shortcode('[df-form]');
		return $form;
	},
1000
);

I recommend the following steps:

  1. Hiding the built-in form with CSS (not really secure if someone finds the hidden form via the developer tools) or overriding it via the template filters Customizing Templates I HivePress Developer Docs - YouTube and replacing it with the custom form block.

  2. Preventing user login via the default API endpoint, by using the hivepress/v1/models/user/login action (to log the user out) or by altering the API route via hivepress/v1/route filter.

add_filter(
	'hivepress/v1/forms/user_login',
	function( $form ) {
		unset($form);
		$form['header'] = do_shortcode('[df-form-login]');
		return $form;
	},
1000
);
add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		unset($form);
		$form['header'] = do_shortcode('[df-form-signup]');
		return $form;
	},
1000
);

I have tried this code and functionality is good,
is this ok?

Yes, it seems to be ok, it unsets all the other form parameters except header, but I can’t say for sure if this will function ok in future updates, some parameters may become required.

Yes, i found a difficulty in replace form , not logging in with email and password, every time need to reset the password.

Can you please suggest proper way to replace the login modals

add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function(){
   jQuery('.hp-modal').addClass('digits-login-modal').attr('type',1);
});
</script>
<?php } );

Third party plugin provided this code.
But Both logins are popingup and not able to hide hivepress login,

I am not good in PHP can i have someone to fix my issue (otp integration), otherwise I should to discontinue hivepress.

Sorry, unfortunately I can’t help with third-party code and adding features that are not in HivePress at the moment - this is beyond our support scope (it includes fixing bugs in the existing features, guidance about the existing features and accepting feature requests). The best way would be integrating the OTP verification process into the existing login form, e.g. you can set a custom redirect for it, to a custom page with OTP verification, you can use third-party form there since it’s a custom page while preventing login via the default form using the hivepress/v1/models/user/login action hook (it’s fired when the user is logged in, so you can use it to logout user immediately, to use another login method instead).

Can you please explain how to do it.

Sorry, there’s no simple code snippet or guidance for this because this requires a custom implementation. If you’re familiar with customizations, please try the following suggestions:

  1. Use a custom function for the hivepress/v1/models/user/login action, to log the user out (and block the default login this way) and perform any initial actions related to OTP (e.g. sending an SMS).

  2. Use a custom function for the hivepress/v1/forms/user_login filter, to set a redirect URL for the login form, this way when the login form is submitted you can redirect it to a custom OTP page.

  3. On the custom OTP page, use some form to accept the OTP received by the user (sent on the user login action) and verify it, then log the user in via the preferred way (e.g. third-party plugin or a custom function).

Hope this helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.