Skip to content

Instantly share code, notes, and snippets.

@furf
furf / how-to.md
Last active June 27, 2022 01:57
Slack invite integration for Google Forms
  1. Create a Google Form with a field to collect email addresses. Pro-tip: use Data Validation to validate string is valid email.
  2. Click View Responses to view form responses in Google Spreadsheets.
  3. Open menu Tools > Script editor...
  4. Paste in Google App Script below and make the following changes:
    • Create a Slack API token and replace the value of SLACK_API_TOKEN.
    • Replace "YOUR_TEAM_NAME" with your team's name in the value for SLACK_API_INVITE_URL.
    • Make sure EMAIL_FIELD_NAME corresponds to the header text of your Google Spreadsheet's email column.
  5. Open menu Resources > Current project's triggers and add a new trigger: onFormSubmit, From spreadsheet, On form submit. Click Save and accept the authorization request to use the script.
  6. You can optionally configure notifications to receive error messages by email.
@wpscholar
wpscholar / create-admin-user.php
Last active February 27, 2024 11:54
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );