Skip to content

Instantly share code, notes, and snippets.

Avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / gist:3c1fe20e6abb04a2e85d
Created Oct 10, 2014
Make the first name not required during EDD checkout
View gist:3c1fe20e6abb04a2e85d
<?php
function pw_edd_purchase_form_required_fields( $required_fields ) {
unset( $required_fields['edd_first'] );
return $required_fields;
}
add_filter( 'edd_purchase_form_required_fields', 'pw_edd_purchase_form_required_fields' );
@pippinsplugins
pippinsplugins / gist:d973776836ab984aea06
Created Sep 3, 2014
Sets an affiliate user's role to a specific role when being added as an affiliate
View gist:d973776836ab984aea06
<?php
/*
* Plugin name: Affiliate role on registration
*/
function pw_affwp_set_role_on_registration( $affiliate_id = 0 ) {
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
$user = new WP_User( $user_id );
$user->add_role( 'affiliate' );
@pippinsplugins
pippinsplugins / gist:f1fa0fa83d556fd31cdc
Created Aug 29, 2014
Basic Ontraport referral tracking for Restrict Content Pro
View gist:f1fa0fa83d556fd31cdc
<?php
/*
* Plugin Name: Restrict Content Pro - OntraPort Referral Tracking
* Description: Very basic referral tracking for onraport and Restrict Content Pro
*/
function pw_rcp_ontraport_referrals( $payment_id, $args, $amount ) {
global $rcp_options;
@pippinsplugins
pippinsplugins / gist:6ef05f7d293cc215a441
Created Jul 28, 2014
Do something when the status of a member in RCP changes
View gist:6ef05f7d293cc215a441
<?php
function pw_rcp_update_role_status_change( $new_status, $user_id ) {
switch( $new_status ) {
case 'expired' :
case 'pending' :
case 'free' :
case 'cancelled' :
@pippinsplugins
pippinsplugins / gist:4061d850852e9d73531a
Created Jul 23, 2014
Example of how to add access to the Members page in Restrict Content Pro to the Editor role
View gist:4061d850852e9d73531a
<?php
function rcp_add_member_caps() {
// gets the editor role
$role = get_role( 'editor' );
// Allow Editors to view Members in Restrict Content Pro
$role->add_cap( 'rcp_view_members' );
}
View gist:ebcf859c0443b161e40c
<?php
/*
* Plugin Name: EDD Redirect to Next Product on Add to Cart
* Description: Automatically redirects the customer to the next product after they have added an item to the cart
* Author: Pippin Williamson
* Version: 0.1
*/
function pw_edd_redirect_to_next_scripts( $download_id = 0 ) {
@pippinsplugins
pippinsplugins / gist:d498bb26d0723ae99f0a
Created Jul 11, 2014
Disable the Stripe payment gateway when a specific Download ID is in the cart
View gist:d498bb26d0723ae99f0a
<?php
function pw_edd_maybe_disable_stripe( $gateways ) {
$disable = false;
$cart_items = edd_get_cart_contents();
if( $cart_items ) {
foreach( $cart_items as $item ) {
@pippinsplugins
pippinsplugins / gist:c6634ef6ee9b65297c85
Last active Sep 12, 2016
Redirect users to specific pages when logging in based on their status in Restrict Content Pro
View gist:c6634ef6ee9b65297c85
<?php
function pw_rcp_login_redirect( $redirect_to, $request, $user ) {
$status = rcp_get_status( $user->ID );
switch( $status ) {
case 'expired' :
case 'pending' :
@pippinsplugins
pippinsplugins / gist:c4c2142e9b3bd2db997c
Last active Aug 29, 2015
Set a member's role in Restrict Content Pro anytime their status changes
View gist:c4c2142e9b3bd2db997c
<?php
function pw_rcp_update_role_status_change( $new_status, $user_id ) {
$role = false;
switch( $new_status ) {
case 'expired' :
case 'pending' :
View functions.php
<?php
function change_author_capabilities() {
$role = get_role( 'shop_vendor' ) ;
$role->add_cap( 'delete_products' );
}
add_action( 'admin_init', 'change_author_capabilities' );