Skip to content

Instantly share code, notes, and snippets.

<?php
use memberpress\courses\helpers as helpers;
use memberpress\courses\models as models;
use memberpress\courses\controllers as controllers;
use memberpress\courses as base;
// Load header
echo helpers\Courses::get_classroom_header();
// Start the Loop.
while ( have_posts() ) :
<?php
function mepr_change_subject($subject, $recipients, $message, $headers) {
if(strpos(strtolower($subject), 'password reset') !== false) {
$subject = 'New Subject - Password Reset';
}
return $subject;
}
add_filter('mepr-wp-mail-subject', 'mepr_change_subject', 10, 4);
<?php
/*
INSTRUCTIONS FOR THIS CODE:
On your RSS URL in Aweber add &allow_aweber=true to the end of it.
Then copy the below code and paste it into a plugin like My Custom Functions or Code Snippets on your site.
This will allow Aweber through the content blocks.
*/
function allow_aweber_through($block, $post, $uri) {
if(isset($_GET['allow_aweber'])) {
<?php if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');} ?>
<?php
$products = $group->products();
$check_products = array();
$credit_card_products = array();
// Find credit card and check memberships.
if(!empty($products)) {
foreach($products as $product) {
<?php
function mepr_validate_emails_signup($errors) {
$allowed_words = array('university'); // ADD ALLOWED WORDS HERE SEPARATED BY COMMAS.
$email = isset($_POST['user_email']) ? trim($_POST['user_email']) : '';
$is_allowed = false;
// If email is empty for some reason or the membership shouldn't be validated, then just don't do anything.
if($_POST['mepr_product_id'] != 123 || empty($email)) {
return $errors;
<?php
function mepr_change_subject($subject, $recipients, $message, $headers) {
if(strpos(strtolower($subject), 'set your new password') !== false) {
$subject = 'New Subject - Set Your New Password';
}
if(strpos(strtolower($subject), 'your new password') !== false) {
$subject = 'New Subject - Your New Password';
}
@DumahX
DumahX / mpcs-all-courses.php
Last active May 6, 2024 10:08
Displays a list of all published MemberPress courses.
<?php
function mpcs_all_courses($atts) {
$content = '';
$courses = get_posts(
array(
'post_type' => 'mpcs-course',
'post_status' => 'publish',
'posts_per_page' => '-1',
'orderby' => 'title',
<?php
function mepr_validate_user_role($errors) {
// Memberships to apply restrictions on.
$membership_ids = array('123', '321', '12345');
// The current membership isn't being validated, so don't do anything else.
if(!in_array($_POST['mepr_product_id'], $membership_ids)) {
return $errors;
}
@DumahX
DumahX / courses_archive_course.php
Created October 4, 2021 12:31
Course Archive Page
<?php
use memberpress\courses as base;
use memberpress\courses\helpers as helpers;
use memberpress\courses\models as models;
// // use memberpress\courses\controllers as controllers;
// use memberpress\courses as base;
use memberpress\courses\lib as lib;
$search = isset($_GET['s']) ? esc_attr($_GET['s']) : '';
$category = isset($_GET['category']) ? esc_attr($_GET['category']) : '';
<?php
$user_id = get_current_user_id();
if ( ! $user_id ) {
return; // Just return if user is not logged in.
}
$query = array(
'posts_per_page' => '-1',
'author' => $user_id,