Skip to content

Wordpress integration example

Chris Bacon edited this page Jun 27, 2018 · 5 revisions

This is a basic example to create Fomo event. Let's assume you are not using composer or another autoloader.

Download fomo-php-sdk

copy src/Fomo to /wp-content/theme/_your-active-theme_/Fomo

add to functions.php

require_once(get_stylesheet_directory().'/Fomo/FomoClient.php');
require_once(get_stylesheet_directory().'/Fomo/FomoEventBasic.php');
require_once(get_stylesheet_directory().'/Fomo/FomoEvent.php');
... more requires if your config needs it ...

Now we have Fomo's code able to use in your website. In this example, we will keep it simple and use it in a template view.

template view

<?php
/**
 * Template Name: Your Page With Fomo
*/
use Fomo\FomoClient;
$client = new FomoClient('add_your_token_here'); // auth token can be found Fomo application admin dashboard (App -> API Access)

use Fomo\FomoEventBasic;
$event = new FomoEventBasic();
$event->event_type_tag = "add_your_event_type_tag_here"; // Event type tag is found on Fomo dashboard (Templates -> Template name)

// this values will be dynamic from your website. Ensure they match the variables you are using on your templates.
$event->title = "Test event";
$event->first_name = "Ryan";
$event->email_address = "[email protected]"; // used to fetch Gravatar for notification image
$event->ip_address = "128.177.108.102"; // used for extracting location parameters (city, province, country)
$event->city = "New York City";
$event->url = "https://www.usefomo.com";


$fomoEvent = $client->createEvent($event);

Check Fomo app to see if event was created.

Clone this wiki locally