Skip to content

Instantly share code, notes, and snippets.

View jrglass's full-sized avatar

Jonathan Glass jrglass

  • Manchester By-The-Sea
View GitHub Profile
@cartpauj
cartpauj / mepr-show-account-nav-shortcode.php
Last active February 29, 2024 02:27
Shortcode to show MemberPress Account page navigation menu on any page
<?php
//
// PASTE SHORTCODE [mepr-account-nav-menu] after adding this snippet to your site
// Use Code Snippets plugin (run snippet only on front end)
// https://wordpress.org/plugins/code-snippets/
//
function mepr_show_nav_menu() {
if(!class_exists('MeprAccountCtrl')) { return; }
$mepr_options = MeprOptions::fetch();
@supercleanse
supercleanse / auto_enroll.php
Last active October 11, 2022 04:14
Automatically create a lifetime transaction for a specific product each time a user registers.
<?php
if(is_plugin_active('memberpress/memberpress.php')) {
add_action( 'user_register', 'mp_auto_enroll' );
//add_action( 'gform_user_registered', 'mp_auto_enroll', 10, 4 );
function mp_auto_enroll($user_id, $user_config=array(), $entry='', $user_pass='') {
$txn = new MeprTransaction();
$txn->user_id = $user_id;
@allybee
allybee / target_blank.js
Last active November 7, 2023 22:40
Add target="_blank" to external links with pure JavaScript.
function targetBlank() {
// remove subdomain of current site's url and setup regex
var internal = location.host.replace("www.", "");
internal = new RegExp(internal, "i");
var a = document.getElementsByTagName('a'); // then, grab every link on the page
for (var i = 0; i < a.length; i++) {
var href = a[i].host; // set the host of each link
if( !internal.test(href) ) { // make sure the href doesn't contain current site's host
a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes