Last active
August 2, 2023 22:03
-
-
Save nikitasinelnikov/445b43e35a67383d578af64cc9641a62 to your computer and use it in GitHub Desktop.
Adds profile permissions to view/edit.
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
function um_custom_can_view_profile( $can_view, $user_id ) { | |
if ( ! is_user_logged_in() ) { | |
if ( user_can( $user_id, 'um_volunteer' ) ) { | |
$can_view = false; | |
} | |
} else { | |
if ( current_user_can( 'um_volunteer' ) && user_can( $user_id, 'um_volunteer' ) ) { | |
$can_view = false; | |
} | |
} | |
return $can_view; | |
} | |
add_filter( 'um_can_view_profile', 'um_custom_can_view_profile', 10, 2 ); | |
function um_custom_pre_profile_shortcode() { | |
add_filter( 'um_redirect_home_custom_url', 'um_custom_redirect_home_custom_url', 10, 3 ); | |
} | |
add_action( 'um_pre_profile_shortcode', 'um_custom_pre_profile_shortcode', 9 ); | |
function um_custom_redirect_home_custom_url( $url, $requested_user_id, $is_my_profile ) { | |
if ( ! $is_my_profile ) { | |
if ( ! is_user_logged_in() ) { | |
if ( user_can( $requested_user_id, 'um_volunteer' ) ) { | |
$url = 'redirect_url_with_notice; | |
} | |
} else { | |
if ( current_user_can( 'um_volunteer' ) && user_can( $requested_user_id, 'um_volunteer' ) ) { | |
$url = 'redirect_url_with_notice; | |
} | |
} | |
} | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment