BuddyDev

Search

Force user profile

  • Participant
    Level: Initiated
    Posts: 5
    Frogbutt on #39440

    First question is wich plugin should we be using?

    https://buddydev.com/plugins/bp-force-profile-photo/ <– says depreciated but has been updated more recently than the below plugin

    or

    https://wordpress.org/plugins/buddypress-profile-completion/

    Second question if we should be using https://wordpress.org/plugins/buddypress-profile-completion/ is there any code similar to the code supplied for the original plugin to ski pages? this code below is provided for the force profile photo plugin but does not work on the newer ” BuddyPress Profile Completion” plugin

    ——————————————————

    Example 1:- Do not redirect on non BuddyPress pages

    /**
    * 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’ );

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #39441

    Hello

    Thank you for posting. Please use “BuddyPress Profile Completion” as it is an advance version of “Force Profile Photo”.

    This plugin provides a filter that allows you to filter the redirect URL. Please check the following:

    
    apply_filters_ref_array( 'buddypress_profile_completion_redirect', array( $redirect_url, $has_fields, $has_photo, $has_cover ) );
    
    

    You can use this to alter the redirect URL. Please let me know if it helps or not

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #39442

    Hello

    An example with the filter. By default, the Profile Completion plugin redirects the user to the specific page under the Profile’s tab e.q. edit profile if not completed his profile field data. But with the following example code you can alter the redirect URL:

    
    
    /**
     * Modify profile completion redirect URL
     *
     * @param string $redirect_url Redirect url.
     * @param bool   $has_fields   Has user completed all required fields?.
     * @param bool   $has_photo    Has user uploaded avatar image?.
     * @param bool   $has_cover    Has user uploaded cover image?.
     *
     * @return string
     */
    function buddydev_modify_profile_completion_redirect_url( $redirect_url, $has_fields, $has_photo, $has_cover ) {
    	$user_id = bp_displayed_user_id();
    
    	// Redirect to profile if not completed his required fields.
    	if ( ! $has_fields ) {
    		$redirect_url = bp_core_get_user_domain( $user_id ) . bp_get_profile_slug();
    	}
    
    	return $redirect_url;
    }
    add_filter( 'buddypress_profile_completion_redirect', 'buddydev_modify_profile_completion_redirect_url', 10, 4 );
    

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 5
    Frogbutt on #39448

    Thanks for clarification. On the code you provided, I am not looking to change the redirect URL, im looking for something similar to what was provided here :

    This code basically SKIPS the redirect all together on NON-Buddypress pages.

    Example 1:- Do not redirect on non BuddyPress pages

    /**
    * 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’ );

    • This reply was modified 3 years, 4 months ago by Frogbutt.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #39450

    Hello,

    Thank you for your clarification. Please use the following code:

    
    
    // Do not check profile completion on none BuddyPress pages.
    add_filter( 'bp_force_profile_completion_skip_check', function ( $skip ) {
    
    	if ( ! is_buddypress() ) {
    		$skip = true;
    	}
    
    	return $skip;
    } );
    
    

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved