Created
April 9, 2021 07:12
-
-
Save wp-user-manager/05ac7070cd6c91494f38f36b6148dd2e to your computer and use it in GitHub Desktop.
WP User Manager - Redirect to current post when logging in from wpDiscuz link
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 | |
add_filter( 'wpdiscuz_login_link', function ( $login_link ) { | |
$login_page = wpum_get_core_page_id( 'login' ); | |
if ( $login_page ) { | |
$login_url = get_permalink( $login_page ); | |
$new_login_url = add_query_arg( [ | |
'redirect_to' => urlencode( get_permalink() . '#comments' ), | |
], $login_url ); | |
$login_link = str_replace( $login_url, $new_login_url, $login_link ); | |
} | |
return $login_link; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to ensure the Login URL is set to the URL of your login page in the wpDiscuz Settings > User Authorization and Profile Data
Then save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).