Password Reset with Code for WordPress REST API

Password Reset with Code for WordPress REST API

Wordpress plugin

Install on Wordpress

App Details

A simple plugin that adds a password reset facility to the WordPress REST API using a code. The process is a two step process:

  1. User requests a password reset. A code is emailed to their registered email address
  2. The user enters the code when setting a new password, which is only set if the code is valid and has not expired

It is also possible to check the validity of a code without resetting the password which enables the possibility of setting the password by other means, or having a two stage process for checking the code and resetting the password if desired.

Default settings are to use an 8 digit code consisting of numbers, upper and lower case letters and special characters, which has a life span of 15 minutes, afterwhich a new code would need to be requested. By default a user can attempt to use or validate a code up to 3 times before automatically invalidating it.

Endpoints

The plugin adds two new endpoints to the REST API:

  • Endpoint: /wp-json/bdpwr/v1/reset-password
    — HTTP Verb: POST
    — Parameters (all required):
    — email

  • /wp-json/bdpwr/v1/set-password
    — HTTP Verb: POST
    — Parameters (all required):
    — email
    — password
    — code

  • /wp-json/bdpwr/v1/validate-code
    — HTTP Verb: POST
    — Parameters (all required):
    — email
    — code

Example Requests (jQuery)

Reset Password

$.ajax({ url: '/wp-json/bdpwr/v1/reset-password', method: 'POST', data: { email: '[email protected]', }, success: function( response ) { console.log( response ); }, error: function( response ) { console.log( response ); }, }); 

Set New Password

$.ajax({ url: '/wp-json/bdpwr/v1/set-password', method: 'POST', data: { email: '[email protected]', code: '1234', password: 'Pa$$word1', }, success: function( response ) { console.log( response ); }, error: function( response ) { console.log( response ); }, }); 

Validate Code

$.ajax({ url: '/wp-json/bdpwr/v1/validate-code', method: 'POST', data: { email: '[email protected]', code: '1234', }, success: function( response ) { console.log( response ); }, error: function( response ) { console.log( response ); }, }); 

Example Success Responses (JSON)

Reset Password

{ "data": { "status": 200 }, "message": "A password reset email has been sent to your email address." } 

Set New Password

{ "data": { "status": 200 }, "message": "Password reset successfully." } 

Validate Code

{ "data": { "status": 200 }, "message": "The code supplied is valid." } 

Example Error Responses (JSON)

Reset Password

{ "code": "bad_email", "message": "No user found with this email address.", "data": { "status": 500 } } 

Set New Password

{ "code": "bad_request", "message": "You must request a password reset code before you try to set a new password.", "data": { "status": 500 } } 

Validate Code

{ "code": "bad_request", "message": "The reset code provided is not valid.", "data": { "status": 500 } } 

Filters

A number of WordPress filters have been added to help customise the process, please feel free to request additional filters or submit a pull request with any that you required.

Filter the length of the code

add_filter( 'bdpwr_code_length' , function( $length ) { return 4; }, 10 , 1 ); 

Filter Expiration Time

add_filter( 'bdpwr_code_expiration_seconds' , function( $seconds ) { return 900; }, 10 , 1 ); 

Filter the date format used by the plugin to display expiration times

add_filter( 'bdpwd_date_format' , function( $format ) { return 'H:i'; }, 10 , 1 ); 

Filter the reset email subject

add_filter( 'bdpwr_code_email_subject' , function( $subject ) { return 'Password Reset'; }, 10 , 1 ); 

Filter the email content

add_filter( 'bdpwr_code_email_text' , function( $text , $email , $code , $expiry ) { return $text; }, 10 , 4 ); 

Filter maximum attempts allowed to use a reset code, default is 3, -1 for unlimmited

add_filter( 'bdpwr_max_attempts' , function( $attempts ) { return 3; }, 10 , 4 ); 

Filter whether to include upper and lowercase letters in the code as well as numbers, default is false

add_filter( 'bdpwr_include_letters' , function( $include ) { return false; }, 10 , 4 ); 

Filter the characters to be used when generating a code, you can use any string you want, default is 0123456789

add_filter( 'bdpwr_selection_string' , function( $string ) { return '0123456789'; }, 10 , 4 ); 

Filter the WP roles allowed to reset their password with this plugin, default is any, example below shows removing administrators

add_filter( 'bdpwr_allowed_roles' , function( $roles ) { $key = array_search( 'administrator' , $roles ); if( $key !== false ) { unset( $roles[ $key ] ); } return $roles; }, 10 , 1 ); 

Filter to add custom namespace for REST API

add_filter( 'bdpwr_route_namespace' , function( $route_namespace ) { return 'xyz/v1'; }, 10 , 1 ); 

Credits

Pricing

Starting from $0 per month.

Check Out the RSS Feed Carousel Widget

By Common Ninja

RSS Feed CarouselTry For Free!

App Info

Rating

Reviewers

9 reviews

Tags

password reset
wp-api

Developed By

dominic_ks

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

RSS Feed Carousel for Wordpress logo

RSS Feed Carousel

Show RSS content with an RSS feed carousel that updates automatically, displays posts in a smooth scrolling layout, and keeps visitors engaged.

Visitor Counter for Wordpress logo

Visitor Counter

Show real time visitor counts with a visitor counter widget that displays live traffic, builds social proof, and boosts engagement.

Video Poll for Wordpress logo

Video Poll

Create interactive video polls that use engaging clips to boost participation, gather insights, and help visitors vote in a more dynamic way.

Event Listings for Wordpress logo

Event Listings

Create event listings with an events board widget that displays upcoming activities clearly, helps visitors discover events, and supports easy management.

Reviews Trust Box for Wordpress logo

Reviews Trust Box

Display ratings from multiple platforms in a reviews trust box that builds credibility, social proof, and boosts conversions.

Section Builder for Wordpress logo

Section Builder

Create structured layouts with a section builder that lets you design custom website sections, customize styles, and organize content for a clearer user experience.

Business Listings for Wordpress logo

Business Listings

Create business listings with a listings widget that presents companies clearly, supports easy organization, and helps visitors find the right services quickly.

Stop Motion Player for Wordpress logo

Stop Motion Player

Create engaging stop motion displays with a stop motion player that turns image sequences into interactive animations to boost creativity and visitor engagement.

Social Share Buttons for Wordpress logo

Social Share Buttons

Add social share buttons so visitors share content to major networks, boost engagement, and drive more referral traffic.

TikTok Carousel for Wordpress logo

TikTok Carousel

Show TikTok videos with a TikTok carousel that arranges clips in a smooth, customizable layout to boost engagement and keep visitors watching.

Scroll to Top for Wordpress logo

Scroll to Top

A scroll to top button that helps visitors move back to the top of long pages quickly, improving navigation and overall browsing flow.

Age Gate for Wordpress logo

Age Gate

Use an age verification popup to validate visitor age, meet regulatory requirements, and ensure only eligible users access restricted content.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms