Skip to content

Instantly share code, notes, and snippets.

View coulterpeterson's full-sized avatar
🤓
Always learning

Coulter Peterson coulterpeterson

🤓
Always learning
View GitHub Profile
@coulterpeterson
coulterpeterson / snippet.php
Created May 17, 2023 18:42
WordPress Shortcode for Outputting Current User's Email Address
<?php
add_shortcode('user_email', function($atts) {
$the_atts = shortcode_atts([
"encode" => 'false'
], $atts);
if( is_user_logged_in() ) {
$current_user = wp_get_current_user();
if( $the_atts['encode'] == 'true' ) {
@coulterpeterson
coulterpeterson / snippet.js
Last active May 16, 2023 18:36
Provide {RowID} Merge Tag in Child Form | GP Nested Forms
/**
* Gravity Wiz // GP Nested Forms // Provide {RowID} Merge Tag in Child Form
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Replaces {RowID} merge tag in the child form with the Row ID while that form is displayed within nested forms.
* Parent element must have a "rowid-merge" CSS class added.
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
@coulterpeterson
coulterpeterson / gw-require-user-autofill-address-once.js
Created May 5, 2023 16:58
Require User to Autofill At Least Once | Gravity Wiz Address Autocomplete
/**
* Gravity Wiz // Gravity Forms Address Autocomplete // Require User to Autofill At Least Once
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete/
*
* Hides a required field you add to your form, and fills it with a value only if the user successfully autofills
* in the form at least once.
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
@coulterpeterson
coulterpeterson / snippet.html
Created May 4, 2023 18:54
Conditionally Hide A Gravity Forms Post Content Merge Tag Based On Its Value
<div id="timekeeping-solution">{Are you interested in a timekeeping solution that would allow employees to easily clock in and out online?:22}</div>
<script>
// When the page is ready
window.addEventListener('load', function () {
if (document.querySelector('body') !== null) { // Some element that should be rendered by now before we execute code
const timekeepingSolution = document.querySelector('#timekeeping-solution');
if( timekeepingSolution.innerHTML == "No" ) {
timekeepingSolution.style.display = "none";
@coulterpeterson
coulterpeterson / gw-update-user-password-after-submission.php
Last active May 25, 2023 16:54
Update User Password After Submission | Gravity Forms
<?php
/**
* Gravity Wiz // Gravity Forms // Update User Password After Submission
* https://gravitywiz.com/
*
* Updates the password for the user ID associated with the inputted email, allowing a custom password reset form.
*
*/
// Update "123" to your form ID, "4" to your "Password" field ID, and "5" to your "Confirm Password" field ID.
@coulterpeterson
coulterpeterson / snippet.js
Created December 20, 2022 14:44
Navigate Broken Tabs in Fusion Builder for #WordPress and #AvadaTheme
➡️ To go from the General Tab to the Design tab:
jQuery('.fusion-tabs #general').css('display','none'); jQuery('.fusion-tabs #design').css('display','block');
➡️ To go from the General Tab to the Animation Tab:
jQuery('.fusion-tabs #general').css('display','none'); jQuery('.fusion-tabs #animation').css('display','block');
➡️ To go from the General Tab to the Background Tab:
jQuery('.fusion-tabs #general').css('display','none'); jQuery('.fusion-tabs #background').css('display','block');
-----------------
@coulterpeterson
coulterpeterson / snippet.sql
Created September 28, 2022 16:29
Find invalid emails in MSSQL
SELECT *
FROM [Accounts]
WHERE EmailType IN ('HOME', 'EC_EMAIL', 'BUS') AND Active = 1 AND EmailAddress NOT LIKE '%_@__%.__%'
@coulterpeterson
coulterpeterson / snippet.html
Created December 21, 2021 19:45
Open Divi Toggle with Button Module OR With Direct Anchor Link to Page
<script>
// What to do when the read more buttons are clicked (they're toggles now)
(function($) {
jQuery(document).ready(function() {
let menuLinks = jQuery('a.read-more'),
toggles = jQuery('.et_pb_toggle');
menuLinks.each(function(){
jQuery(this).click(function(){
let clickedLinkTarget = jQuery(this).attr('href');
@coulterpeterson
coulterpeterson / snippet.js
Created December 4, 2021 00:08
Dynamically update favicon with JavaScript
// Thanks https://stackoverflow.com/a/260876
//var link = document.querySelector("link[rel~='icon']"); // Can use this one if you expect only one existing favicon; requires a few tweaks below
let links = document.querySelectorAll("link[rel*='icon']");
if (!links) {
let link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
@coulterpeterson
coulterpeterson / functions.php
Created November 4, 2021 18:18
Add custom WordPress fonts
<?php
function load_scripts() {
wp_enqueue_script( 'clattering-font', get_stylesheet_directory_uri() . '/Clattering.ttf', array() );
}
add_action( 'wp_enqueue_scripts', 'load_scripts' );