Developer Docs - Trust Swiftly
  • Developer Documentation
  • Web
    • Integration
    • Button Link
    • WordPress
    • WebView iOS and Android
    • Bubble ID Verify Integration
    • FlutterFlow Identity Verification
    • Webflow ID Verification
    • Zapier Identity Verification
  • API
    • Getting an API Key
    • Authentication
    • Users
    • Reverify User
    • Documents
    • Stats
    • Templates
    • Errors
    • Pagination
    • Filtering and Sorting
    • Rate Limits
  • Webhooks
    • Setup and Handling Webhooks
    • Webhook Code Examples
  • Hosted Link
    • Share hosted link
  • Self Sign Up and Create Autofill
    • Configure self verifications
    • Prefill User Creation
  • Single Sign On
    • SAML2 SSO (Okta, etc)
    • Rippling SSO App
    • Azure Entra ID SAML
  • Notifications
    • Slack
    • Zoho Cliq
    • Email and Web Push
  • Stripe App
    • Install and Demo Guide
    • Disconnect Stripe App
  • References
    • Supported Documents
  • Links
    • Trustswiftly.com
    • Sign Up
Powered by GitBook
On this page
  • WooCommerce Plugin
  • Sample WordPress Code
  1. Web

WordPress

To integrate Trust Swiftly with Wordpress it can be done in a similar manner as the HTML integration and link.

PreviousButton LinkNextWebView iOS and Android

Last updated 10 months ago

WooCommerce Plugin

Our plugin for WooCommerce can be used to verify identities before and after checkout for basic verifications.

For other integrations with Wordpress custom code is advised to create users.

Sample WordPress Code

Example code can be copied into functions.php which allows for using a shortcode to generate a verification link [trustlink]

add_shortcode('trustlink', 'generate_trustlink');
function generate_trustlink(){
    if ( is_user_logged_in() ) {
        $user_id=get_current_user_id();
        $metaData=json_decode(get_user_meta($user_id,'trust_user_data',true));
        $endpoint = 'https://test.trustswiftly.com/api/v1/users/'.$metaData->id.'/verify-url';
        $user_info = get_userdata($user_id);
        $user_email = $user_info->user_email;
        $body = [
            'email' => $user_email,
        ];

        $body = wp_json_encode($body);

        $options = [
            'body' => $body,
            'headers' => [
                'Authorization' => 'Bearer $api_key',
                'Content-Type' => 'application/json',
            ],
            'returntranser' => true,
            'timeout' => 60,
            'redirection' => 10,
            'data_format' => 'body',
        ];

        $response = wp_remote_post($endpoint, $options);
        $responseData=json_decode($response['body']);
        return $responseData->short_url;
    }else{
        return false;
    }
}
add_action('user_register', function ( $user_id ) {
    $endpoint = 'https://test.trustswiftly.com/api/v1/users';
    $user_info = get_userdata($user_id);
    $user_email = $user_info->user_email;
    $body = [
        'email' => $user_email,
    ];

    $body = wp_json_encode( $body );

    $options = [
        'body'        => $body,
        'headers'     => [
                'Authorization'=>'Bearer $api_key',
                'Content-Type' => 'application/json',
        ],
        'returntranser'=>true,
        'timeout'     => 60,
        'redirection' => 10,
        'data_format' => 'body',
    ];

    $response =wp_remote_post( $endpoint, $options );

    add_user_meta( $user_id, 'trust_user_data', $response['body'],true);
});
https://wordpress.org/plugins/trust-swiftly-verification/