BuddyDev

Search

[Resolved] Force profile photo upload on a specific page

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #20685

    Hello Brajesh,

    Please how can I force profile photo upload on a specific page using the BuddyPress Force profile Photo plugin. I am using your 2 custom code to skip specific pages.

     /**
     * Example to show skipping urls from the BuddyPress Force Profile Photo plugin
     *
     * @param boolean $skip
     *
     * @return bool whether to skip or not?
     */
    function buddydev_skip_urls_from_force_profile_photo( $skip ) {
     
        if ( bp_is_members_directory() ) {
            $skip = true;
        }
     
        return $skip;
    }
    add_filter( 'bp_force_profile_photo_skip', 'buddydev_skip_urls_from_force_profile_photo' ); 
     /**
     * Do not redirect users on non bp pages.
     *
     * @param bool $skip should we skip or redirect.
     *
     * @return bool
     */
    function buddydev_skip_redirect_on_non_bp_pages( $skip ) {
     
        if ( ! is_buddypress() ) {
            $skip = true;
        }
     
        return $skip;
    }
     
    add_filter( 'bp_force_profile_photo_skip', 'buddydev_skip_redirect_on_non_bp_pages' ); 

    Now I want to enable Force profile Photo on this specific page https://website.com/new-post/ while still using this 2 custom codes you provided.

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #20690

    Please add the following lines too

    
    /**
     * Do not skip redirect on new post.
     *
     * @param bool $skip should we skip?
     *
     * @return bool
     */
    function buddydev_dont_skip_redirect_on_new_post( $skip ) {
    
    	if ( is_page( 'new-post' ) ) {
    		$skip = false;
    	}
    
    	return $skip;
    }
    
    add_filter( 'bp_force_profile_photo_skip', 'buddydev_dont_skip_redirect_on_new_post', 20 );
    
    

    That should do it. I am assuming ‘new-post’ is a page.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #20704

    Hello,

    This code below is preventing the code you sent from working

     /**
     * Buddydev force follow 6 members function.
     */
    function buddydev_check_or_redirect() {
    	// Force profile photo active?
    	$fp_active = class_exists( 'BD_Force_User_Avatar_Helper' );
    
    	// skip if logged and on non bp page.
    	if ( is_user_logged_in() && ! is_buddypress() ) {
    		if ( $fp_active ) {
    			remove_action( 'bp_template_redirect', array(
    				BD_Force_User_Avatar_Helper::get_instance(),
    				'check_or_redirect',
    			), 1 );
    		}
    
    		return;
    	}
    
    	if ( ! function_exists( 'bp_follow_get_the_following_count' ) || ! is_user_logged_in() || is_super_admin() ) {
    		return;
    	}
    
    	$is_dir = bp_is_members_directory();
    
    	// if we are on directory and force profile is not active
    	// return.
    	if ( $is_dir && ! $fp_active ) {
    		return;
    	}
    
    	$follow_count = bp_follow_get_the_following_count( array( 'object_id' => get_current_user_id() ) );
    
    	if ( $follow_count >= 4 ) {
    		return;
    	}
    
    	if ( $is_dir && $fp_active ) {
    		remove_action( 'bp_template_redirect', array(
    			BD_Force_User_Avatar_Helper::get_instance(),
    			'check_or_redirect',
    		), 1 );
    
    		return;
    	}
    
    	bp_core_add_message( __( 'Please follow 4 or more members to continue.' ), 'error' );
    
    	bp_core_redirect( bp_get_members_directory_permalink() );
    }
    
    add_action( 'bp_template_redirect', 'buddydev_check_or_redirect', 0 ); 
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #20705

    Hi Tosin,

    I am sorry for the inconvenience.
    In future, Please do share all related code or topic in one post to allow me work over them easily.

    I will look at it later today and help you.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Jack Kelly on #21359

    Hi,

    Is it possible to get the “Please upload your profile photo to start using this site.” message to show as a java script alert or as a popup as people are missing the notification on their profiles and it is confusing for them?

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #21383

    Hi Jack,
    I am sorry, It is not possible to show the javascript for it. I will suggest updating the theme to make the notice a bit more prominent. That should help in long run.

    All the best.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Jack Kelly on #21399

    okay thanks 🙂

The topic ‘ [Resolved] Force profile photo upload on a specific page’ is closed to new replies.

This topic is: resolved