# Yoti WordPress Plugin

This repository contains the tools you need to quickly integrate your WordPress backend with Yoti so that your users can share their identity details with your application in a secure and trusted way. The plugin uses the Yoti PHP SDK. If you're interested in finding out more about the SDK, click [here](https://github.com/getyoti/yoti-php-sdk).

## Requirements

This plugin works with the WordPress Business Plan package.

## Installing the plugin

You can install the Yoti WordPress plugin in two ways:

### By importing the plugin into your project

1. Log on to your Wordpress Admin Dashboard e.g. `https://www.wordpressurl.org.uk/wp-admin`
2. Navigate to `Plugins > Add New`
3. Search for Yoti, install and activate the plugin

### By using this repository (For MacOS and Linux users)

1. Clone this repository
2. Run `./pack-plugin.sh`. This will download the Yoti PHP SDK and place it in the plugin directory
3. On completion of step 2, you will have a file called `yoti-wordpress-edge.zip`.
4. Upload this file to your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`.
5. Once installed, click on `Activate Plugin`.

## Setting up your Yoti Application

After you registered your [Yoti](https://www.yoti.com/), access the [dashboard](https://www.yoti.com/dashboard/login) to create a new application.

Specify the basic details of your application such as the name, description and optional logo. These details can be whatever you like and will not affect the plugin's functionality.

The `Data` tab - Specify any attributes you'd like users to share. You must select at least one. If you plan to allow new user registrations, we recommended choosing `Given Name(s)`, `Family Name` and `Email Address` at a minimum.

The `Integration` tab - Here is where you specify the callback URL. This can be found on your Yoti settings page in your WordPress admin dashboard. **NOTE**: If you get redirected to your WordPress frontpage instead of the Admin area, simply add `/wp-admin` to the URL.

## Plugin Setup

To set things up, navigate on WordPress to `Settings > Yoti`.
You will be asked to add the following information:

* `Yoti App ID` is the unique identifier of your specific application.
* `Yoti Scenario ID` is used to render the inline QR code.
* `Yoti SDK ID` is the SDK identifier generated by Yoti Dashboard in the Key tab when you create your app. Note this is not your Application Identifier, which is needed by your client-side code.
* `Company Name` will replace WordPress wording in the warning message displayed on the custom login form.
* `Yoti PEM File` is the application pem file. It can be downloaded only once from the Keys tab in your Yoti Dashboard.

Please do not open the .pem file as this might corrupt the key and you will need to create a new application.

## Settings for new registrations

`Only allow existing Wordpress users to link their Yoti account` - This setting allows a new user to Register and Log in by using their Yoti. A new user who registeres this way will be set to the `Subscriber` role in WordPress. If enabled, when a new user tries to scan the Yoti QR code, they will be redirected back to the login page with an error message displayed.

`Attempt to link Yoti email address with Wordpress account for first time users` - This setting enables linking a Yoti account to a WordPress user if the email from both platforms is identical.

## Docker

We provide a WordPress Docker container that includes the Yoti plugin.

### Setup

Clone this repository and go into the folder:

```shell
cd yoti-wordpress
```

Rebuild the images if you have modified the `docker-compose.yml` file:

```shell
docker-compose build --no-cache
```

Build the containers:

```shell
docker-compose up -d
```

After the command has finished running, go to [http://localhost:7000](http://localhost:7000) and follow the instructions.

The Yoti plugin will be installed alongside WordPress. Activate it and follow our [plugin setup process](#plugin-setup).

### Removing the Docker containers

Run the following commands to remove docker containers:

```shell
docker-compose stop
docker-compose rm
```

## Support

For any questions or support please email [sdksupport@yoti.com](mailto:sdksupport@yoti.com).
Please provide the following to get you up and working as quickly as possible:

* Computer type
* OS version
* Version of WordPress being used
* Screenshot

Once we have answered your question we may contact you again to discuss Yoti products and services. If you’d prefer us not to do this, please let us know when you e-mail.
