Skip to content

Instantly share code, notes, and snippets.

Joshua Nelson joshuadavidnelson

Block or report user

Report or block joshuadavidnelson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / grid-block.scss
Created Jul 31, 2019
css grid example with modernizr assisted fallback
View grid-block.scss
.grid-block {
float: left;
}
.grid {
$grid-gap: 9px;
// Columns!
@media screen and ( min-width: 600px ) { // responsive grid
display: grid;
@joshuadavidnelson
joshuadavidnelson / change-wp-user-password.sql
Created Jul 24, 2018
SQL for updating a user password in WordPress
View change-wp-user-password.sql
UPDATE wp_users
SET user_pass = MD5('newpassword')
WHERE ID = 55;
View scripts-to-footer-example.php
@joshuadavidnelson
joshuadavidnelson / custom-route-notification-multiple-fields.php
Last active Dec 8, 2017
Per emailed question, utilizing the example in my blog post "User Dropdown List & Custom Notification Routing in Gravity Forms" for multiple fields that have the custom 'user-emails' CSS class to email multiple people
View custom-route-notification-multiple-fields.php
<?php
/**
* Change the sent to email address in the notification
*
* @author Joshua David Nelson, josh@joshuadnelson.com
**/
// Route to user address from drop down list, update the '1' to the ID of your form
add_filter( 'gform_notification_1', 'route_user_email_notification', 10, 3 );
function route_user_email_notification( $notification, $form , $entry ) {
@joshuadavidnelson
joshuadavidnelson / gist:57210d6218e4039288973d0045a10159
Created May 5, 2017 — forked from dustyf/gist:b6e72a7a7fd05de9598e
Example WordPress Simple JSON Endpoint Plugin
View gist:57210d6218e4039288973d0045a10159
<?php
/**
* Plugin Name: WDS GIF API
* Plugin URI: http://webdevstudios.com
* Description: Adds a Custom Post Type to store GIFs and an API JSON Endpoint to access GIFs by a tag.
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/
View gf-upload-file-to-post-attachment.php
<?php
/**
* Associate an uploaded file with a post on form submission in Gravity Forms
*
* This is specific to a comment on my post about connecting GF with ACF
*
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/#comment-13186
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
@joshuadavidnelson
joshuadavidnelson / gf-upload-file-to-media-library.php
Last active Jan 7, 2019
Create a media file on upload, requires the JDN_Create_Media_File class from https://gist.github.com/joshuadavidnelson/164a0a0744f0693d5746
View gf-upload-file-to-media-library.php
<?php
/**
* Create a new media library entry with a file upload on gravity form submission.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_add_image_to_media_library', 10, 2 );
function jdn_add_image_to_media_library( $entry, $form ) {
View gravity-form-to-acf-image-field-fornt-end-posting.php
<?php
/**
* Connect a Gravity Form File Upload Field to an ACF Image Field.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_set_acf_gallery_field', 10, 2 );
function jdn_set_acf_gallery_field( $entry, $form ) {
$gf_images_field_id = 7; // the upload field id
@joshuadavidnelson
joshuadavidnelson / get-responsive-image.php
Created Mar 22, 2017
Generate a img tag for responsive images in WordPress
View get-responsive-image.php
<?php
/**
* Get the responsive image.
*
* @param string $image_id
* @param string $image_size optional
*
* @return string $output
*/
function get_respsonsive_image( $image_id, $size = 'medium' ) {
View notification.php
<?php
// Route to user address from drop down list, update the '1' to the ID of your form – I am using this on 6 forms so I have removed the ID requirement
add_filter( 'gform_notification', 'welcome_email', 10, 3 );
function welcome_email( $notification, $form , $entry ) {
foreach( $form['fields'] as &$field ) {
// Similar to above, find the right field
if( $field['type'] != 'select' || strpos($field['cssClass'], 'user-emails') === false )
continue;
// Pull out the user id selected, by the field id and the $entry element
You can’t perform that action at this time.