Skip to content

Instantly share code, notes, and snippets.

View ronalfy's full-sized avatar
🏠
Working from home

Ronald Huereca ronalfy

🏠
Working from home
View GitHub Profile
@ronalfy
ronalfy / pmpro-smk-renew-message.php
Created March 6, 2020 00:10
Paid Memberships Pro Renew Message to User
<?php
function pmpro_renew_smk() {
if ( ! is_user_logged_in() ) {
return;
}
?>
<div id="custom_renew_message" class="alert">This is a custom renew message shown to the user.</div>
<?php
}
add_action( 'pmpro_checkout_after_level_cost', 'pmpro_renew_smk' );
@ronalfy
ronalfy / pmpro-invoice-code-helfer.php
Created March 6, 2020 00:58
Paid Memberships Pro Invoice Code
<?php
function pmpro_invoice_code_helfer( $code ) {
$invoice_code = get_option( 'pmpro_helfer_invoice_code', array() );
if ( empty( $invoice_code ) ) {
$invoice_code = array(
'prefix' => 'IAW',
'increment' => 1,
);
update_option( 'pmpro_helfer_invoice_code', $invoice_code );
}
@ronalfy
ronalfy / pmpro-sponsored-add-on-tre.php
Created March 6, 2020 17:14
Paid Memberships Pro Sponsored Add On
<?php
global $pmprosm_sponsored_account_levels;
$pmprosm_sponsored_account_levels = array(
6 => array(
'main_level_id' => 6, //redundant but useful
'sponsored_level_id' => array(7), //array or single id
'seats' => 100
),
);
@ronalfy
ronalfy / pmpro-text-replacement-pmpro-account-shortcode.php
Created March 6, 2020 22:18
Paid Memberships Pro Text Replacement for pmpro_account Shortcode
<?php
function pmpro_level_cost_text_son( $text ) {
$text = str_replace( ' maintenant', '', $text );
return $text;
}
add_filter( 'pmpro_level_cost_text', 'pmpro_level_cost_text_son', 10, 1 );
@ronalfy
ronalfy / pmpro-redirect-user-after-login.php
Created March 11, 2020 15:33
Paid Memberships Pro Redirect User After Login
<?php
function pmpro_redirect_after_login( $redirect_to, $request, $user ) {
if ( ! empty( $user ) && ! empty( $user->ID ) && function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
$level = pmpro_getMembershipLevelForUser( $user->ID );
if ( 1 == $level ) {
$redirect_to = home_url();
}
}
return $redirect_to;
}
@ronalfy
ronalfy / pmpro-invite-codes-custom-account-page.php
Created March 12, 2020 15:12
Paid Memberships Pro - Invite Codes On Custom Account Page
<?php
/*
Show an invite code on the account page.
*/
function pmproio_custom_the_content_account_page($content)
{
global $current_user, $pmpro_pages, $post;
// First check if PMPro is active.
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return $content;
@ronalfy
ronalfy / pmpro-pending-approval-confirmation-logout.php
Last active March 13, 2020 15:16
Paid Memberships Pro Log Out User After Confirmation Pending Approval
<?php
function pmpro_custom_pages_shortcode_confirmation( $content ) {
if ( is_user_logged_in() ) {
if ( class_exists( 'PMPro_Approvals' ) ) {
global $current_user;
$approval_levels = PMPro_Approvals::getApprovalLevels();
foreach ( $approval_levels as $level ) {
if ( ! PMPro_Approvals::isApproved( $current_user->ID, $level ) ) {
wp_logout();
break;
@ronalfy
ronalfy / pmpro-lock-down-url.php
Last active March 16, 2020 18:44
Paid Membership Pro - Lock Down URL
<?php
/**
* This recipe will redirect non members away from a page
* according to the current URL address
*
* 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/
*/
@ronalfy
ronalfy / pmpro-add-on-learn-dash.php
Last active September 15, 2023 12:26
Paid Memberships Pro - Add On Packages Plus LearnDash
<?php
global $pmpro_addon_pages_for_courses;
// 28 is the page ID; 24 is the course ID.
// 30 is the page ID; 26 is the course ID.
$pmpro_addon_pages_for_courses = array(
28 => 24,
30 => 26,
);
function pmproap_learndash_template_redirect()
{
@ronalfy
ronalfy / pmpro-add-discount-code-mailchimp-export.php
Last active June 24, 2020 15:52
Paid Memberships Pro - Add Discount Code to MailChimp Export
<?php
/**
* This recipe merges any discount codes that a user has used to the MailChimp export.
*
* 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/
*/
function my_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) {