Here are some sample snippets helpful for tweaking the functionality of the WooCommerce Memberships plugin. If you’re looking for more details on modifying Memberships or “For Developers” samples, please view our developer documentation.
Note that these snippets are unsupported and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring a WooExpert to assist.
Member Area
↑ Voltar Para o TopoRemove Cancel action from My Memberships table
↑ Voltar Para o Topo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Only copy the opening php tag if needed | |
*/ | |
function sv_edit_my_memberships_actions( $actions ) { | |
// remove the "Cancel" action for members | |
unset( $actions['cancel'] ); | |
return $actions; | |
} | |
add_filter( 'wc_memberships_members_area_my-memberships_actions', 'sv_edit_my_memberships_actions' ); | |
add_filter( 'wc_memberships_members_area_my-membership-details_actions', 'sv_edit_my_memberships_actions' ); |
Remove End Date Column from My Memberships
↑ Voltar Para o Topo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only copy opening php tag if needed | |
// Remove the "End Date" column from the My Memberships table | |
function sv_remove_membership_end_date_column( $columns ) { | |
unset( $columns['membership-end-date'] ); | |
return $columns; | |
} | |
add_filter( 'wc_memberships_my_memberships_column_names', 'sv_remove_membership_end_date_column' ); |
Remove Type Column from My Content Area
↑ Voltar Para o Topo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only copy opening php tag if needed | |
// Removes the "Type" column from the "My Content" section of the member area | |
function sv_members_area_content_remove_column( $columns ) { | |
// unset the "type" column, which shows post, page, project, etc | |
if ( isset( $columns['membership-content-type'] ) ) { | |
unset( $columns['membership-content-type'] ); | |
} | |
return $columns; | |
} | |
add_filter( 'wc_memberships_members_area_my_membership_content_column_names', 'sv_members_area_content_remove_column' ); |
Remove Description Column from My Products Area
↑ Voltar Para o Topo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only copy opening php if needed | |
// Removes the product short description / excerpt column from "My Products" | |
function sv_members_area_products_table_columns( $columns ) { | |
if ( isset( $columns['membership-product-excerpt'] ) ) { | |
unset( $columns['membership-product-excerpt'] ); | |
} | |
return $columns; | |
} | |
add_filter('wc_memberships_members_area_my_membership_products_column_names', 'sv_members_area_products_table_columns', 10, 1 ); |
Blog & Posts
↑ Voltar Para o TopoShow Lock Icon on Restricted Posts
↑ Voltar Para o TopoShop Pages
↑ Voltar Para o TopoRemove Member Discount Badges
↑ Voltar Para o Topoadd_filter( 'wc_memberships_member_discount_badge', '__return_empty_string' );
Disable Discount Stacking
↑ Voltar Para o Topoadd_filter( 'wc_memberships_allow_cumulative_member_discounts', '__return_false' );
Integrations
↑ Voltar Para o TopoAdd Social Login Buttons to Restriction Messages
↑ Voltar Para o TopoOther Snippets
↑ Voltar Para o TopoGrant Access only from Completed Orders
↑ Voltar Para o TopoIf you want to add statuses (such as custom statuses) that grant access, our developer documentation can help.
Create My Memberships Shortcode
↑ Voltar Para o TopoMore Snippets
↑ Voltar Para o TopoTable of Contents
↑ Voltar Para o TopoNote that these snippets are UNSUPPORTED and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring a Woo Expert to assist.