Skip to content

Commit 9a6528f

Browse files
committed
added: frontend profile visibility control
1 parent f17a47c commit 9a6528f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

includes/actions.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,20 @@ function wpum_reset_password_redirect() {
399399
wp_safe_redirect( $url );
400400
exit;
401401
}
402+
403+
/**
404+
* Restrict profile page when disabled.
405+
*
406+
* @return void
407+
*/
408+
function wpum_restrict_profile_page() {
409+
410+
$is_profile_disabled = wpum_get_option( 'disable_profiles' );
411+
$profile_page = wpum_get_core_page_id( 'profile' );
412+
413+
if ( true === boolval( $is_profile_disabled ) && is_page( $profile_page ) ) {
414+
wp_safe_redirect( home_url() );
415+
die();
416+
}
417+
}
418+
add_action( 'template_redirect', 'wpum_restrict_profile_page' );

includes/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ function wpum_get_account_page_tabs() {
707707
],
708708
];
709709

710-
if ( ! wpum_get_core_page_id( 'profile' ) ) {
710+
if ( ! wpum_get_core_page_id( 'profile' ) || boolval( wpum_get_option( 'disable_profiles' ) ) === true ) {
711711
unset( $tabs['view'] );
712712
}
713713

includes/wpum-admin/class-wpum-options-panel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ public function register_settings( $settings ) {
339339
),
340340
],
341341
'profiles' => [
342+
array(
343+
'id' => 'disable_profiles',
344+
'name' => __( 'Disable User Profiles', 'wp-user-manager' ),
345+
'desc' => __( 'Enable this option to disable user profiles from frontend.', 'wp-user-manager' ),
346+
'type' => 'checkbox',
347+
),
342348
array(
343349
'id' => 'guests_can_view_profiles',
344350
'name' => __( 'Allow Guests to View Profiles', 'wp-user-manager' ),

0 commit comments

Comments
 (0)