BuddyDev

Search

Force redirect users with empty profile photo to a specific page

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27432

    Hello Brajesh,

    I have a specific page with the ID 46589, How can I force redirect users with empty profile photos on the specific page with ID 46589.

    1.) When users with empty profile photo goes to the page with ID 46589 they will all be redirected automatically to another page with ID 77465.

    2.) but if users have uploaded their profile photos then they should be exempted from the condition above and be able to access page ID 46589 successfully without any redirect.

    3.) the redirect should only affect users with empty profile photos.

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #27433

    Hi Tosin,
    thank you for the question.

    is there a chance that you are using on eof our plugin
    – Buddyress Force profile Photo
    – BuddyPress profile Completion
    – BuddyPressUser with Uploaded Avatars

    I am asking because these plugins do save the user’s avatar presence in database. BuddyPress does not keep this detail out of the box.

    Please let me know and I or my team will assist you.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27436

    I am using buddypress profile completion plugin

    It would also be awesome if the code can support multiple page Ids

    Thanks

    • This reply was modified 4 years, 11 months ago by Tosin.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #27454

    Hi Tosin,
    thank you for the patience.

    Here is the code

    
    
    // filter redirect url.
    add_filter( 'buddypress_profile_completion_redirect', function ( $redirect_url ) {
    	return get_permalink( 77465 );
    } );
    
    // filter skip option.
    add_filter( 'bp_force_profile_completion_skip_check', function ( $skip ) {
    
    	if ( is_page( 77465 ) ) {
    		$skip = true;
    	}
    
    	return $skip;
    } );
    
    

    1. It assumes you have profile restrictions applied.
    2. It redirects user to page 77465 if their profile photo is not available.
    3. It does not change the behaviour/access for the page 46589 if the user has a profile photo.

    hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27455

    Thank you very much

    But I don’t want the code to be executed globally throughout the site.

    The code should only be executed when users visit the page with ID 46589

    The code should only execute on this page 46589

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #27479

    Hi Tosin,
    I am sorry for the delayed reply.

    The above code is very minimal and will not have any effect on your page loading speed or site efficiency.

    I do not see a reason to write code for specific page. Please do let me know if you have other reasons.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27490

    Thank you for your reply, the reason why I need this is that I have a plugin for posting ads on the frontend and in order to solve the problem of trust and identity with posted ads.
    I need only users who are interested in posting ads to upload their profile photo. I don’t want the code to affect users who are not interested in posting ads, so the code should execute only on a specific page.

    1. Page ID 46589 contains the advert posting form

    2. When users with empty profile photo goes to the page with ID 46589 they will all be redirected automatically to another page with ID 77465 where they will upload their profile photo.

    3. page with ID 77465 contains a custom plugin for uploading profile photos.

    4. other users who are not interested in posting ads should not be affected by the code, so the code should only execute on the Page ID 46589.

    Thanks

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27521

    Any feedback sir thanks

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #27597

    Any reply sir thanks

You must be logged in to reply to this topic.

This topic is: not resolved