Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / replace-spaces-with-underscores.php
Last active April 8, 2021 20:30 — forked from travislima/replace_spaces_with_underscores.php
Convert capital letters to lowercase and replace spaces with underscores "_" in order to standardize usernames.
<?php // Do not copy this tag.
/**
* Convert capital letters to lowercase and replace all spaces with an underscore when
* new users register for Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin -
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_user_registration_changes( $userdata ) {
@pbrocks
pbrocks / open-new-posts-to-non-members.php
Last active August 3, 2018 03:01 — forked from strangerstudios/open_new_posts_to_non_members.php
PMPro Customizations to allow non-members to view restricted posts if they are less than 30 days old.
<?php // do not include this line
/**
* Allow non-members to view restricted posts if they are less than 30 days old.
*
* Add this code to a custom plugin.
*
* Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*/
/**
* [open_new_posts_to_non_members description]
@pbrocks
pbrocks / pmpro-cancelled-level.php
Last active March 10, 2022 18:36 — forked from strangerstudios/pmpro_cancelled_level.php
Move PMPro members to another level when they cancel.
<?php
/**
* By default cancelled members are changed to level 0. This recipe changes that behavior to give them a "cancelled" level that
* you have created for that purpose. Can be used to downgrade someone to a free level if they cancel.
*/
/**
* [pmpro_after_change_membership_level_default_level description]
*
* @param [type] $level_id [description]
* @param [type] $user_id [description]
@pbrocks
pbrocks / existing code to git repo
Created July 20, 2018 19:03 — forked from zenideas/existing code to git repo
Adding existing source to remote git repo
If you've got local source code you want to add to a new remote new git repository without 'cloning' the remote first, do the following (I often do this - you create your remote empty repository in bitbucket/github, then push up your source)
1. Create the remote repository, and get the URL such as git://github.com/youruser/somename.git
2. If your local GIT repo is already set up, skips steps 2 and 3
3. Locally, at the root directory of your source, git init
4. Locally, add and commit what you want in your initial repo (for everything,
git add .
@pbrocks
pbrocks / show-pmpro-address-fields-on-profile.php
Last active April 13, 2021 18:41 — forked from ideadude/show_pmpro_address_fields_on_edit_profile.php
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
<?php
/**
* Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
*/
/**
* show_pmpro_address_fields_on_edit_profile Grabs the values from the billing fields which get filled in during checkout and displays on User Profile.
*
* @return array Array of Register Helper field objects
*/
function show_pmpro_address_fields_on_edit_profile() {
@pbrocks
pbrocks / pmprorh-init-buddypress-fields.php
Last active May 9, 2023 10:49 — forked from ideadude/my_pmprorh_init_buddypress_fields.php
Example of defining PMPro Register Helper Fields Synchronized to BuddyPress XProfile Fields
<?php
/**
* Based on the Register Helper example.
* We've added a "buddypress" option for each field
* set to the XProfile name we used when setting up
* the fields in the BuddyPress extended profile.
* If the PMPro BuddyPress Add On is activated
* then the fields will be synchronized.
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/
@pbrocks
pbrocks / code.js
Created July 5, 2018 22:21 — forked from MaruscaGabriel/code.js
DIVI theme JavaScript code snippets
//Open external links into new tab
<script type="text/javascript">
jQuery('a').filter(function () {
return this.hostname != window.location.hostname;
}).attr('target', '_blank');
</script>
//Adding Fly-in Animations To Any Divi Section, Row and Module
//thanks to Gino Quiroz : https://quiroz.co/adding-fly-in-animations-to-any-divi-module/
//Below are the CSS Class groups for each animation.
@pbrocks
pbrocks / customizer-links.php
Created July 5, 2018 22:19 — forked from slushman/customizer-links.php
How to link into the WordPress Customizer
<?php
//phpDoc for new PMPro function
/**
* A description of what the function does.
*
* @param {array, string, int, objext} {$variable_name} {Short description}
* @return {array, string, int, mixed, object} {$variable_name} {Short description}
*
* {@internal Any To-Dos etc.}
*
@pbrocks
pbrocks / test-php-session-vars.php
Last active June 21, 2018 16:19 — forked from ideadude/test_php_session_vars.php
Test if PHP Session Variables are working.
<?php
session_start();
/**
* Test if PHP Session Variables are working.
* Step 1: Add this code into a custom plugin or in a PHP file you know is being executed.
* Step 2: Navigate to /?test=123. You should see a blank old value and 123 as the new value.
* Step 3: Navigate to /?test=456. You should see 123 as the old value and 456 as the new value.
* If you see a blank old value again, that means that session variables are not enabled or otherwise broken.
* If the timestamp at the top is not being updated, the page may be cached.
* Step 4: Remove this code.