Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
@woogist
woogist / exclude-post-type-from-content-restriction-options.php
Created February 2, 2026 08:26
[WooCommerce Memberships] Remove post types from the membership plan restriction options
<?php // only copy this line if needed
/**
* Remove post types from the membership plan restriction options
* Example: remove Sensei Messages from post types that can be restricted
*
* @param array $blacklist the array of post types to exclude from restriction options
* @return array $blacklist the updated array of post types to exclude
*/
function sv_wc_memberships_add_post_type_to_blacklist( $blacklist ) {
@woogist
woogist / add-membership-status.php
Created February 2, 2026 08:24
[WooCommerce Memberships] Add custom user membership statuses
<?php // only copy this line if needed
/**
* Add custom user membership statuses
*
* @param array $statuses the array of membership statuses
* @return array $statuses the updated status array
*/
function sv_wc_memberships_add_membership_statuses( $statuses ) {
@woogist
woogist / grant-membership-access-for-custom-order-statuses.php
Created February 2, 2026 08:23
[WooCommerce Memberships] Grant membership access for custom order statuses
<?php // only copy this line if needed
/**
* Membership access is already granted when orders are processing or completed
* Add membership access for custom order statuses as well
*
* Example: grant membership access for "Shipped" and "Invoice Paid" orders during purchase cycle as well
* Use the appropriate action for your custom order status
*/
function sv_wc_memberships_grant_access_for_custom_order_statuses() {
@woogist
woogist / only-grant-access-for-completed-orders.php
Created February 2, 2026 08:14
[WooCommerce Memberships] Removes membership access for processing orders
<?php // only copy this line if needed
/**
* Removes membership access for processing orders
* so access is only granted at when orders are complete
*/
function sv_wc_memberships_remove_processing_access() {
// make sure Memberships is active first
if ( function_exists( 'wc_memberships' ) ) {
@woogist
woogist / add-restricted-post-lock-icon.php
Created February 2, 2026 08:13
[WooCommerce Memberships] Display a FontAwesome lock icon next to the post title if a member does not have access
<?php // only copy if needed
/**
* Display a FontAwesome lock icon next to the post title if a member does not have access
* with WooCommerce Memberships.
*
* REQUIRES FontAwesome to be loaded already
*
* @param string $post_title the post title
* @param int $post_id the WordPress post ID
@woogist
woogist / add-author-column-to-my-content.php
Created February 2, 2026 08:08
[WooCommerce Memberships] Add an "Author" column to the "My Content" table in the members area
<?php // only copy this line if needed
/**
* Add an "Author" column to the "My Content" table in the members area
*
* @param array $columns the columsn in the "My Content" table
* @return array $columns the updated array of columns
*/
function sv_wc_memberships_my_content_table_add_column( $columns ) {
@woogist
woogist / rename-member-area-section-links.php
Created February 2, 2026 08:07
[WooCommerce Memberships] Rename the section links for the "Member Area"
@woogist
woogist / remove-my-memberships-end-date-column.php
Created February 2, 2026 08:06
[WooCommerce Memberships] Remove the "End Date" column from the My Memberships table
<?php // only copy this line if needed
/**
* Remove the "End Date" column from the My Memberships table
*
* @param array $columns the columns in the "My Memberships" table
* @return array $columns the updated array of columns
*/
function sv_wc_memberships_remove_end_date_column( $columns ) {
@woogist
woogist / change-content-delayed-access-message.php
Created February 2, 2026 08:04
[WooCommerce Memberships] Change the "content delayed" message displayed to members who will have access, but not yet
<?php // only copy this line if needed
/**
* Change the "content delayed" message displayed to members who will have access, but not yet
* Example: change the delayed content message for the "Projects" post type
*
* @param string $message the message html
* @param string[] $args {
* @type string $context whether the message appears in the context of a notice or elsewhere
* @type \WP_Post $post the post object
@woogist
woogist / allow-order-editing-with-custom-status.php
Created February 2, 2026 06:52
[WooCommerce Order Status Manager] Allow Order editing for custom statuses
<?php
/**
* Allow Order editing for custom statuses
*
* @param bool $editable if the order is editable
* @param \WC_order $order
* @return bool if the order is editable for this status
*/
function sv_wc_order_status_manager_order_is_editable( $editable, $order ) {