Skip to content

Instantly share code, notes, and snippets.

@sonipb
sonipb / my_pmpro_confirmation_redirect.php
Created August 1, 2017 07:52 — forked from strangerstudios/my_pmpro_confirmation_redirect.php
Redirect Paid Memberships Pro Confirmation to Another Page Based on Level
/*
This code will redirect users from the default PMPro confirmation page to a specific page depending on their level.
Set the confirmation_pages array. Array keys should be membership level ids and the values are the page ids. So array(1=>2) will redirect membership level with id = 1 to the page with id = 2.
*/
function my_pmpro_confirmation_redirect()
{
$confirmation_pages = array(1 => 2); //change this use your membership level ids and page ids
global $pmpro_pages;
@sonipb
sonipb / att.html
Created July 11, 2017 06:01 — forked from igorbenic/att.html
Extending the WordPress Media Uploader: Custom Fields | http://www.ibenic.com/extending-wordpress-media-uploader-custom-fields
<input type="text" name="attachments[123][field_name]" />
@sonipb
sonipb / ajaxify-cart.php
Created July 4, 2017 03:19 — forked from DanielSantoro/ajaxify-cart.php
AJAX Update Cart thats added to Template File Manually (
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php).
// Used in conjunction with https://gist.github.com/DanielSantoro/1d0dc206e242239624eb71b2636ab148
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
@sonipb
sonipb / functions.php
Created July 4, 2017 03:14 — forked from jameskoster/functions.php
Query whether WooCommerce is activated
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}
}
@sonipb
sonipb / woocommerce-login-logout-cart-handling.php
Created June 30, 2017 18:23 — forked from yawalkar/woocommerce-login-logout-cart-handling.php
WooCommerce - Login / Logout Cart Handling and redirects
<?php
/**
* Redirect users to custom URL based on their role after login and restore the cart
*
* @param string $redirect
* @param object $user
* @return string
*/
function wp_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user