Skip to content

Instantly share code, notes, and snippets.

@cartpauj
cartpauj / memberpress-hooks.php
Last active July 20, 2023 17:46
Various Subscription and Transaction status hooks for MemberPress with some helpful comments
<?php
//Capture a new member signup. Only ever triggers once for each new member.
//Does not trigger for exising members who have subscribed to a Membership before.
//
//The user may not be logged in when this is called
//as it is triggered when a user is added over the REST API,
//and also when a user is added from the dashboard (MemberPress -> Members -> Add New)
function mepr_capture_new_member_signup_completed($event) {
$user = $event->get_data();
$txn_data = json_decode($event->args);
@damiencarbery
damiencarbery / cmb2-repeater-demo-display-data.php
Last active September 9, 2023 02:53
CMB2 Repeater Demo - a simple example
<?php
add_filter( 'the_content', 'crd_append_post_links' );
function crd_append_post_links( $content ) {
if ( is_page() ) {
$post_links_data = get_post_meta( get_the_ID() );
if ( isset( $post_links_data[ 'blog_group' ][ 0 ] ) ) {
$blog_list = maybe_unserialize( $post_links_data[ 'blog_group' ][ 0 ] );
$posts_list = '<ul>';
foreach ( $blog_list as $post_info ) {
@sheabunge
sheabunge / autoload.php
Last active June 27, 2023 03:35
Basic PHP class autoloader that follows the WordPress coding standards for class names and class filenames
<?php
namespace Shea\Example_Plugin;
/**
* Enable autoloading of plugin classes in namespace.
*
* @param $class_name
*/
function autoload( $class_name ) {