Skip to content

Commit a1a17bb

Browse files
authored
Merge pull request #252 from WPUserManager/#248
Added: frontend profile visibility control
2 parents f17a47c + 10faf27 commit a1a17bb

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

includes/actions.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,19 @@ 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+
$profile_page = wpum_get_core_page_id( 'profile' );
410+
411+
if ( $profile_page && is_page( $profile_page ) && true === boolval( wpum_get_option( 'disable_profiles' ) ) ) {
412+
wp_safe_redirect( home_url() );
413+
die();
414+
}
415+
}
416+
417+
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 frontend user profiles.', '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)