Skip to content

Instantly share code, notes, and snippets.

View samjco's full-sized avatar

Sam C. samjco

View GitHub Profile
@samjco
samjco / redirect-subscriber.php
Created April 24, 2016 07:51 — forked from kcpt-steven-kohlmeyer/redirect-subscriber.php
Wordpress: Redirect subscribers from accessing admin.
<?php
global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( user_can( $current_user, "subscriber" ) ) {
// Disable admin bar for subscribers
show_admin_bar(false);
@samjco
samjco / gist:a114e090a211355b2dcbc6195bda0eed
Created July 19, 2017 05:34 — forked from scottopolis/gist:07c555b9dd0581497f0b
Styling for Display Posts Shortcode
/* Author: Scott Bolinger
* Author URI: http://apppresser.com
*
* Styling for Display Posts Shortcode plugin for use with the AppTheme. Add this code to a child theme style.css file.
* Plugin information: http://www.billerickson.net/shortcode-to-display-posts/
*
*/
ul.display-posts-listing {
list-style-type: none;
@samjco
samjco / cpt_in_wp_submenu.php
Created January 5, 2018 18:58 — forked from johnregan3/cpt_in_wp_submenu.php
Add Custom Post Type to WordPress Plugin Submenu (Hack)
<?php
/*
Plugin Name: Nerfherder Plugin
Plugin URI: https://gist.github.com/johnregan3/6133389
Description: Demonstration of how to add Custom Post Types to Submenu Items
Author: John Regan
Author URI: http://johnregan3.com
Version: 1.0
*/
@samjco
samjco / ListFieldRowTotal
Created January 27, 2022 16:36 — forked from ensostyle/ListFieldRowTotal
Count the number of rows in a Gravity Forms list field and store the result in another field.
<script>
function ListFieldRowCount( listField, totalField ) {
var totalRows = jQuery( listField ).find('table.gfield_list tbody tr').length;
jQuery( totalField ).val( totalRows ).change();
}
function ListFieldRowTotal( formId, fieldId, totalFieldId ) {
var listField = '#field_' + formId + '_' + fieldId;
var totalField = '#input_' + formId + '_' + totalFieldId;
ListFieldRowCount( listField, totalField );
jQuery( listField ).on( 'click', '.add_list_item', function() {