Created
June 23, 2019 09:50
-
-
Save mahfelwp/0a4f23104d21e4dbae4d2229bf831772 to your computer and use it in GitHub Desktop.
Force user to choose pic for profile avatar in buddypress
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 | |
function bp_force_user_to_set_profile_avatar() { | |
if ( ! is_user_logged_in() ) { | |
return; | |
} | |
$user_id = get_current_user_id(); | |
if ( ! bp_get_user_has_avatar( $user_id ) && bp_current_action() != 'change-avatar' ) { | |
bp_core_add_message( __( 'please, set avatar for your profile, if you dont choose any picture for your profile avatar, you cant use website features', 'textdomain' ), 'error' ); | |
bp_core_redirect( bp_loggedin_user_domain() . buddypress()->profile->slug . '/change-avatar/' ); | |
} | |
} | |
add_action( 'template_redirect', 'bp_force_user_to_set_profile_avatar' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment