Skip to content

Instantly share code, notes, and snippets.

View markbiek's full-sized avatar

Mark Biek markbiek

View GitHub Profile
class Person extends Model {
use AlgoliaEloquentTrait;
public $indices = [‘my-index’];
public function getAlgoliaRecord() {
return array_merge($this->toArray(), [
‘addresses’ => $this->addresses->toArray(),
‘contacts’ => $this->contacts->toArray()
]);
class Person extends Model {
use AlgoliaEloquentTrait;
public $indices = [‘my-index’];
public function getAlgoliaRecord() {
return array_merge($this->toArray(), [
‘addresses’ => $this->addresses->toArray(),
‘contacts’ => $this->contacts->toArray(),
‘type’ => ‘person'
<?php
//Check to make sure the token is valid
if (!isset($_POST['token']) || $_POST['token'] != SLACK_TOKEN) {
throw new Exception("Shenanigans!");
}
echo "Hello World!"
<?php
//Check to make sure the token is valid
if (!isset($_POST['token']) || $_POST['token'] != SLACK_TOKEN) {
throw new Exception("Shenanigans!");
}
/*
* This sends a message back to the user immediately so they know something's happening.
* The `ignore_user_abort` allows the script to keep running,
@markbiek
markbiek / index.html
Created November 16, 2016 21:57
Social Media Icons - mojs
<div class="main">
<div class="notice" id="main-notice">
Turn your sound on and click an icon!
</div>
<div class="content">
<div id="circle1" data-note="c" class="circle"><i class="fa fa-facebook-square" aria-hidden="true"></i></div>
<div id="circle2" data-note="c-sharp" class="circle"><i class="fa fa-twitter-square" aria-hidden="true"></i></div>
<div id="circle3" data-note="d" class="circle"><i class="fa fa-instagram" aria-hidden="true"></i></div>
<div id="circle4" data-note="e" class="circle"><i class="fa fa-google-plus-square" aria-hidden="true"></i></div>
<div id="circle5" data-note="e-flat" class="circle"><i class="fa fa-linkedin-square" aria-hidden="true"></i></div>
$args (
'to' => Array(),
'subject' => String,
'headers' => Array(),
'attachments' => Array(),
'message' => String,
)
add_filter('wp_mail', 'handle_wp_mail');
function handle_wp_mail($args) {
if ($args['subject'] == 'Welcome to YOUR SITE') {
$newMessage = <<<EOT
<h2>Welcome to YOUR SITE</h2>
<p>Dear User,</p>
<p>Thanks for registering!</p>
EOT;
$newMail = [
add_filter('wp_mail', 'handle_wp_mail');
function handle_wp_mail($args) {
if ($args['subject'] == 'Welcome to YOUR SITE') {
$wpdb = $GLOBALS['wpdb'];
$email = $args['to'][0];
$user = get_user_by('email', $email);
//Generate a new user_activation_key (eg password reset key)
//This allows us to create a link that a new user can click to set their initial password
$key = wp_generate_password(20, false);
add_action('user_register', 'handle_user_register', 10, 1);
function handle_user_register($user_id) {
/*
* When a new user registers, write all POST values to user_meta.
* This way, they're accessible on when the new-user email is sent through wp_mail.
* Otherwise values like first & last name aren't accessible in the email
*/
foreach ($_POST as $key => $val) {
update_user_meta($user_id, $key, $_POST[$key]);
}
$newMessage = <<<EOT
<h2>Welcome, {$userMeta['first_name'][0]}</h2>
EOT;