Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / my_restricted_pages_require_user_login.php
Last active May 4, 2023 12:46
Restrict specific pages in your WordPress site for logged in users only.
<?php
/**
* Restrict specific pages in your WordPress site for logged in users only.
*
*/
function my_restricted_pages_require_user_login() {
global $current_user;
// Allow logged in users.
if ( is_user_logged_in() ) {
@kimcoleman
kimcoleman / teae_duplicate_usermeta_to_xprofile.php
Created September 9, 2019 21:51
Duplicate TEAE usermeta fields to xProfile Fields
<?php
/**
* Duplicate TEAE usermeta fields to xProfile Fields
*
*/
function teae_duplicate_usermeta_to_xprofile( ) {
global $wpdb;
$fields = array(
'alternate_phone'=>'261',
'body_number_(jal/sal)_1'=>'205',
@kimcoleman
kimcoleman / aatherapy_pmprorh_init.php
Created September 24, 2019 22:00
Register Helper Custom Fields for aatherapy.org
<?php
// Register Helper Custom Fields for PMPro
function aatherapy_pmprorh_init() {
//don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
//define the fields
$fields = array();
@kimcoleman
kimcoleman / my_woocommerce_get_price_html.php
Created October 28, 2019 11:48 — forked from messica/my_woocommerce_get_price_html.php
Display membership pricing along with regular pricing.
<?php
// Display membership pricing along with regular pricing.
function my_woocommerce_get_price_html($price, $product) {
// Get all levels.
$all_levels = pmpro_getAllLevels(true, true);
// Get original price.
$reg_price = wc_price($product->get_regular_price());
@kimcoleman
kimcoleman / add_my_cred_to_pmpro_checkout.php
Created October 31, 2019 11:23
Add myCred points at checkout based on membership level ID.
<?php
/**
* Add myCred points at checkout based on membership level ID.
* Optionally apply points only to members that select a recurring membership.
*
*/
function add_my_cred_to_pmpro_checkout( $user_id, $morder ) {
// Bail if myCred doesn't exist.
if ( ! function_exists( 'mycred_add' ) ) {
@kimcoleman
kimcoleman / add_new_cpts_pmproap_supported_post_types.php
Created November 4, 2019 00:15
Filter to add additional post types for protection and individual sale using Addon Packages for Paid Memberships Pro.
<?php
/**
* Filter to add additional post types for protection and individual sale using Addon Packages for Paid Memberships Pro.
* You should also install the Custom Post Type (CPT) Membership Access Add On so that your CPT can be properly restricted.
* https://www.paidmembershipspro.com/add-ons/custom-post-type-membership-access/
*
*/
function add_new_cpts_pmproap_supported_post_types( $post_types ) {
$post_types[] = 'custom_courses';
return $post_types;
@kimcoleman
kimcoleman / custom_pmprodlm_shortcode_download_content_filter.php
Created November 11, 2019 19:12
Hide the "Membership Required:" and level names from the [download] shortcode output when using Download Monitor and the Download Monitor Integration for Paid Memberships Pro Add On.
<?php
/**
* Hide the "Membership Required:" and level names from the [download] shortcode output
* when using Download Monitor and the Download Monitor Integration for Paid Memberships Pro Add On.
*
*/
add_filter( 'pmprodlm_shortcode_download_show_membership_required_filter', '__return_false' );
@kimcoleman
kimcoleman / twenty_twenty_pmpro.css
Created November 22, 2019 17:09
Custom CSS for using Paid Memberships Pro with the Twenty Twenty WordPress 5.3+ Theme
/* General Table Styles Adjustments */
.pmpro_table {
border: none;
}
.pmpro_table th,
.pmpro_table td {
border: none;
padding: 10px 0;
}
.pmpro_table td {
@kimcoleman
kimcoleman / my_pmprosl_custom_shortcode.php
Last active December 4, 2019 16:18 — forked from LMNTL/my_pmprosl_custom_shortcode.php
Use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
<?php
/**
* Use a custom shortcode with the Social Login Add On for Paid Memberships Pro (Requires v.3 or above)
*
*/
function my_pmprosl_custom_shortcode( $shortcode ) {
// Edit this line to change the shortcode displayed on the checkout page.
return '[TheChamp-Login title="Use your Social Account to Login"]';
}
add_filter( 'pmprosl_login_shortcode', 'my_pmprosl_custom_shortcode' );
@kimcoleman
kimcoleman / my_pmpro_memberslist_extra_cols.php
Last active December 7, 2019 15:30 — forked from strangerstudios/my_pmpro_memberslist_extra_cols.php
Add a custom column to the Memberships > Members admin page for a user field added via Register Helper using the PMPro hook method.
<?php
/**
* Add a custom column to the Memberships > Members admin page for a user field
* added via Register Helper using the PMPro hook method.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/