Skip to content

Instantly share code, notes, and snippets.

View labsecrets's full-sized avatar

LabSecrets labsecrets

View GitHub Profile
@bueltge
bueltge / post-process.php
Created June 24, 2011 21:08
WordPress Custom Post Type: Insert post via Frontend
<?php
/**
* post-process.php
* make sure to include post-process.php in your functions.php. Use this in functions.php:
*
* get_template_part('post-process');
*
*/
function do_insert() {
if( 'POST' == $_SERVER['REQUEST_METHOD']
@strangerstudios
strangerstudios / pmpro-redirect-non-members.php
Created November 2, 2011 02:58
Paid Memberships Pro Redirect Non-members to Login/Homepage
/*
Redirect to login or homepage if user is logged out or not a member
Add this code to your active theme's functions.php file.
*/
function my_template_redirect()
{
global $current_user;
$okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id'));
@trepmal
trepmal / scroll-to-top-admin-bar.php
Created November 15, 2011 00:46
WordPress - Scroll-To-Top Admin Bar
<?php
/*
Plugin Name: Scroll-To-Top Admin Bar
Description: Click anywhere on the Admin Bar that doesn't have a predefined purpose (links, input), and it'll scroll you to the top
Author: Kailey Lampert
Author URI: http://kaileylampert.com
*/
add_action( 'wp_head', 'add_jq' );
add_action( 'admin_head', 'add_jq' );
@farinspace
farinspace / bbpress-hooks.php
Created November 17, 2011 07:53
Generate a list of hooks and filters for bbpress 2.0.1
<?php
// place and run in ./plugins/bbpress/bbp-themes
$dirs = array( './bbp-twentyten', './bbp-twentyten/bbpress' );
$actions = array();
$filters = array();
@markjaquith
markjaquith / no-howdy.php
Created December 25, 2011 04:16
Removes "Howdy" from the WordPress 3.3 toolbar
<?php
/*
Plugin Name: No Howdy
Description: Removes "Howdy, " from the toolbar
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@strangerstudios
strangerstudios / gist:1894897
Created February 23, 2012 20:29
Adding Shipping Address to Paid Memberships Pro
<?php
/*
Plugin Name: PMPro Shipping
Plugin URI: https://gist.github.com/gists/1894897/
Description: Add shipping to the checkout page and other updates.
Version: .2.1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Note that this plugin requires PMPro 1.3.19 or higher to function fully.
<?php
/**
* Database emtpying and file removing class.
*
* Truncates all necessary tables in the defined database and removes
* any files uploaded by the demo user.
*
* @since 1.0.0
*
* @author Thomas Griffin
@strangerstudios
strangerstudios / gist:3845777
Created October 6, 2012 18:50
All Access Levels with Paid Memberships Pro and PMPro-Addon-Packages .1.2+
/*
Set levels as "all access levels" so members of these levels will be able to view all Addon Packages.
Requires Paid Memberships Pro and the pmpro-addon-packages plugin.
*/
function my_pmproap_all_access_levels($levels, $user_id, $post_id)
{
//I'm just adding the level, but I could do some calculation based on the user and post id to programatically give access to content
$levels = array(16);
return $levels;
}
@strangerstudios
strangerstudios / hide_old_posts_from_members.php
Last active May 17, 2021 15:57
Paid Memberships Pro: Hide Old Posts From New Members
/*
This code will create a content filter for all pages and posts to remove access to posts that were published before a member's join date. Only posts or pages which require membership will be hidden. Note that pages and posts that require membership will still be hidden from non-members regardless of the publish date.
The params passed are:
$hasaccess - (bool) what PMPro thinks about whether the user has access
$thepost - (post object) the post being checked, usually the current post
$theuser - (user object) the user being checked, usually the current user
$post_membership_levels - (array of levels) the levels this post requires (if any)
*/
add_filter("pmpro_has_membership_access_filter", "hide_old_posts_from_members", 10, 4);
@nerrad
nerrad / fix-bbpress-roles-in-s2member.php
Created November 20, 2012 19:37
Fix for s2member and bbPress 2.2 plus new roles
<?php
/*
Plugin Name: Fix bbPress roles for s2member
Plugin URI: http://roughsmootheng.in
Version: 1.0
Description: This plugin adds s2member roles to the user_role_map for bbPress.
Author: Darren Ethier
Author URI: http://www.roughsmootheng.in
*/