Skip to content

Commit

Permalink
fix(wc-memberships): WC for Teams join-team link; team in my-account (#…
Browse files Browse the repository at this point in the history
…3540)

* fix(wc-memberships): prevent RAS from hijacking WC for Teams links

* fix: show "My Membership" links in My Account menu for team members

---------

Co-authored-by: dkoo <[email protected]>
  • Loading branch information
adekbadek and dkoo authored Nov 13, 2024
1 parent de27f39 commit 489ce0f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions includes/plugins/class-teams-for-memberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Teams_For_Memberships {
public static function init() {
add_filter( 'newspack_ras_metadata_keys', [ __CLASS__, 'add_teams_metadata_keys' ] );
add_filter( 'newspack_esp_sync_contact', [ __CLASS__, 'handle_esp_sync_contact' ] );
add_filter( 'newspack_my_account_disabled_pages', [ __CLASS__, 'enable_members_area_for_team_members' ] );
}

/**
Expand Down Expand Up @@ -101,6 +102,26 @@ public static function handle_esp_sync_contact( $contact ) {

return $contact;
}

/**
* Enable Members Area for team members only. Team owners/managers get access to the "Teams" menu instead.
*
* @param array $disabled_wc_menu_items Disabled WooCommerce menu items.
*
* @return array Updated disabled WooCommerce menu items.
*/
public static function enable_members_area_for_team_members( $disabled_wc_menu_items ) {
if ( ! function_exists( 'wc_memberships_for_teams_get_teams' ) ) {
return $disabled_wc_menu_items;
}
if (
in_array( 'members-area', $disabled_wc_menu_items, true ) &&
! empty( \wc_memberships_for_teams_get_teams( \get_current_user_id(), [ 'role' => 'member' ] ) )
) {
$disabled_wc_menu_items = array_values( array_diff( $disabled_wc_menu_items, [ 'members-area' ] ) );
}
return $disabled_wc_menu_items;
}
}

Teams_For_Memberships::init();
5 changes: 5 additions & 0 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,11 @@ public static function render_third_party_auth() {
* @return string Filtered template path.
*/
public static function replace_woocommerce_auth_form( $template, $template_name ) {
// Allow template rewriting for `woocommerce-memberships-for-teams` plugin. This includes
// a link to join a team.
if ( is_int( stripos( $template, 'woocommerce-memberships-for-teams' ) ) ) {
return $template;
}
if ( 'myaccount/form-login.php' === $template_name ) {
$template = dirname( NEWSPACK_PLUGIN_FILE ) . '/includes/templates/reader-activation/login-form.php';
}
Expand Down
5 changes: 4 additions & 1 deletion includes/reader-revenue/my-account/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@
}
}


// Fixes an issue with form display caused by Newspack Theme CSS.
.entry-content p {
word-wrap: normal;
}
}

/* stylelint-disable-next-line */
Expand Down

0 comments on commit 489ce0f

Please sign in to comment.