Skip to content

Instantly share code, notes, and snippets.

@rocketgeek
rocketgeek / class-wp-members-woocommerce-integration.php
Last active April 6, 2023 14:01
Patch for WP_Members_WooCommerce_Integration object class when no existing settings are passed to the constructor
<?php
class WP_Members_WooCommerce_Integration {
public $add_my_account_fields;
public $add_checkout_fields;
public $add_update_fields;
public $product_restrict;
public function __construct( $wpmem ) {
@rocketgeek
rocketgeek / show_my_posts_shortcode.php
Last active February 17, 2023 14:08
Display a list of membership posts a user has access to
<?php // do not include this line.
/**
* Adds a custom shortcode to display membership restricted
* posts that a user has access to.
*
* shortcode: [show_my_posts]
*/
add_shortcode( 'show_my_posts', 'my_show_my_posts' );
function my_show_my_posts( $atts, $content, $tag ) {
@rocketgeek
rocketgeek / class-wp-members-pwd-reset.php
Created February 11, 2023 14:42
pending workaround for core integration with security when password generator is used
<?php
/**
* An object class for WP-Members Password Reset.
*
* @since 3.3.5
* @since 3.3.8 Rebuild processing to utilize WP native functions and user_activation_key.
*/
class WP_Members_Pwd_Reset {
/**
@rocketgeek
rocketgeek / class-wp-members-user-search.php
Created January 11, 2023 18:49
Temporary fix for user search collation issues
<?php
/**
* The WP_Members Admin User Search Class.
*
* An object class to improve the backend user search. Allows
* searching by selected meta keys as defined in the plugin
* settings. Hooks into pre_user_query.
*
* Modified from Better User Search:
* https://wordpress.org/plugins/better-user-search/
@rocketgeek
rocketgeek / api.php
Created January 11, 2023 15:53
Possible patch for wpmem_use_custom_dialog()
<?php
/**
* WP-Members API Functions
*
* This file is part of the WP-Members plugin by Chad Butler
* You can find out more about this plugin at https://rocketgeek.com
* Copyright (c) 2006-2022 Chad Butler
* WP-Members(tm) is a trademark of butlerblog.com
*
* @package WP-Members
@rocketgeek
rocketgeek / class-wp-members-pwd-reset.php
Created December 13, 2022 16:45
Potential update to password reset to add WP error to WP-Members error object if the user object contains an error.
<?php
/**
* An object class for WP-Members Password Reset.
*
* @since 3.3.5
* @since 3.3.8 Rebuild processing to utilize WP native functions and user_activation_key.
*/
class WP_Members_Pwd_Reset {
/**
@rocketgeek
rocketgeek / create_wp_site.bat
Last active November 8, 2022 14:24
batch file: create/delete wordpress site in xampp
:: This is for spinning up installs for dev work, so don't consider this for
:: production applications. It creates everything off a single entry variable
:: so that you don't have to mess with unnecessary details. The site name and
:: username are the same (a single input), as are the database and db user.
:: The passwords for the initial WP user and the db user are generic "pass".
:: PHP, WP-CLI, and MYSQL all need to be path environment variables.
:: If you get errors that indicate something is not recognized as an internal
:: or external command, make sure you have these in your PATH.
@rocketgeek
rocketgeek / rm.bash
Created September 3, 2022 14:42
remove all but a single file in a directory using ssh
# No dirs:
rm -- !(file.txt)
# If dirs:
rm -rf -- !(file.txt)
# If extglob is not enabled:
shopt -s extglob
@rocketgeek
rocketgeek / api.php
Last active July 12, 2022 13:48
admin API with new functions for custom user views
<?php
/**
* WP-Members Admin API Functions
*
* This file is part of the WP-Members plugin by Chad Butler
* You can find out more about this plugin at https://rocketgeek.com
* Copyright (c) 2006-2022 Chad Butler
* WP-Members(tm) is a trademark of butlerblog.com
*
* @package WP-Members
@rocketgeek
rocketgeek / php_scripts_with_wp.php
Last active December 30, 2021 13:45
Run php scripts from the command line with full access to WordPress functions.
<?php
/**
* A utility script to load WordPress to run
* php scripts directly from the command line.
*/
if ( php_sapi_name() !== 'cli' ) {
die( "This script is meant to be run from the command line" );
}