Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround to avoid crashing bbPress' frontend profile page #414

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions class-two-factor-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public function init() {
* @see https://wordpress.org/plugins/jetpack/
*/
add_filter( 'two_factor_rememberme', array( $this, 'jetpack_rememberme' ) );

/**
* bbPress
*
* Workaround for profile page breakage
* @see https://github.com/WordPress/two-factor/issues/175
*/
add_action( 'wp', array( $this, 'bbpress_remove_twofactor' ) );
}

/**
Expand Down Expand Up @@ -52,4 +60,16 @@ public function jetpack_rememberme( $rememberme ) {
public function jetpack_is_sso_active() {
return ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'sso' ) );
}

/**
* Helper function to apply bbPress workaround at the right time.
*
* @return void
*/
public function bbpress_remove_twofactor() {
if ( function_exists('bbp_is_single_user_edit') && bbp_is_single_user_edit() ) {
remove_action( 'show_user_profile', array( 'Two_Factor_Core', 'user_two_factor_options' ) );
remove_action( 'edit_user_profile', array( 'Two_Factor_Core', 'user_two_factor_options' ) );
}
}
}
Loading