Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block bhays

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
bhays / brh-tec-demote.php
Created May 22, 2019
WordPress plugin that will set Tribe Events Calendar events to draft status 1 day after event ends.
View brh-tec-demote.php
* Plugin Name: TEC Demote Events
* Plugin URI:
* Description: Set expired events as drafts one day after end date.
* Version: 1.0.0
* Author: Ben Hays
* Author URI:
* License: GPL-2.0+
* License URI:
bhays / add-class-to-hidden-gravityforms-field.php
Last active Apr 17, 2019
Add inputName as class to hidden fields and inputs for Gravityforms
View add-class-to-hidden-gravityforms-field.php
add_filter( 'gform_field_css_class', 'hidden_field_css_class', 10, 3 );
function hidden_field_css_class( $classes, $field, $form ) {
if( $field->type == 'hidden' ){
$classes .= ' '.$field->inputName;
return $classes;
bhays / email-only-password-reset.php
Last active Feb 26, 2018
Allow email only for WordPress password reset requests
View email-only-password-reset.php
// Return error if email is not set for password retrieval
add_action( 'lostpassword_post', 'email_only_lostpassword_post', 10, 1 );
function email_only_lostpassword_post( $errors ){
if( !is_email($_POST['user_login']) ){
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid email addreess.'));
return $errors;
// Translate some login page text
bhays / acf-page-by-template.php
Last active Jul 22, 2016
ACF extension to select pages by specified page template only. Include file in functions.php
View acf-page-by-template.php
function include_field_types_acf_pages_by_template( $version ) {
add_action('acf/include_field_types', 'include_field_types_acf_pages_by_template');
// exit if accessed directly
if( ! defined( 'ABSPATH' ) ) exit;
// check if class already exists

Keybase proof

I hereby claim:

  • I am bhays on github.
  • I am bhays ( on keybase.
  • I have a public key whose fingerprint is 8833 BDFF 8365 C003 10C9 559A D681 0C00 7868 739C

To claim this, I am signing this object:

bhays / Typeahead-BS3-css
Created Aug 2, 2013
Bootstrap 3 style fixes for using Typeahead.js
View Typeahead-BS3-css
.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
.tt-hint {
display: block;
width: 100%;
height: 38px;
padding: 8px 12px;
font-size: 14px;
View WP-Translate-Strings
// Translate theme strings
function mytranslate_filter_gettext( $translated, $original, $domain ) {
// Array of original strings and what they should be replaced with
$strings = array(
'Contribute Now' => 'Donate Now',
if ( isset( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
bhays / GF Submit Disable
Created Jul 30, 2013
Change 'Submit' button to 'Processing...' and disable it
View GF Submit Disable
add_filter('gform_pre_render', 'disable_submit');
function disable_submit($form) {
<script type="text/javascript">
$('#gform_submit_button_<?php echo $form['id']; ?>').on('click', function(event){
var submitCopy = $(this).clone();
submitCopy.prop('id', '').prop('disabled', true).prop('value', 'Processing...').insertAfter($(this));
bhays / Quantity Discounts
Last active Nov 27, 2017
Auto discount prices based on quantities in Gravity Forms. Uses a percentage based approach.
View Quantity Discounts
$.fn.quantityDiscounts = function(options) {
// set up default options
var defaults = {
discountColor: '#FF0000',
discounts: [
{ limit: 174, discount: .75, text: "25% Discount Applied"},
{ limit: 139, discount: .80, text: "20% Discount Applied"},
You can’t perform that action at this time.