BuddyDev

Search

[Resolved] Redirect users immediately after profile photo upload

  • Participant
    Level: Master
    Posts: 439
    Daniel on #47316

    Hi guys,

    That’s a nice feature, to which php file can I add the code to redirect user after successfully upload and crop profile photo?

    Thanks for the input.

    Regards
    Daniel

  • Keymaster
    (BuddyDev Team)
    Posts: 22213
    Brajesh Singh on #47322

    Hi Tosin,
    You can use

    
    bp_is_user_change_avatar()
    

    for that purpose.

    @danieleherat
    Thank you.

    You can put it in wp-contet/plugins/bp-custom.php

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 439
    Daniel on #47341

    Hi Brajesh,

    Sorry I’m not a php programmer, could you please just tell me how to put my url please? I have pasted your code below again, I want that the redirect will be to https://www.mywebsite/members/me

    /**
     * Redirect user on successful php upload and crop.
     */
    add_action( 'bp_enqueue_scripts', function () {
        // you can set the url value to anything.
    	$url = trailingslashit( trailingslashit( bp_get_members_directory_permalink() ) . 'me/' . bp_get_members_invitations_slug() );
    	ob_start();
    	?>
        bp.Avatar.Attachment.on( 'change:url', function( data ) {
            if( data.get('object') == 'user' ) {
                window.location="<?php echo esc_url( $url ); ?>";
            }
        } );
    	<?php
    	$script = ob_get_clean();
    	wp_add_inline_script( 'bp-avatar', $script, 'after' );
    }, 100 );

    Thank you!

    Regards
    Daniel

    Regards
    Daniel

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2502
    Ravi on #47356

    Hello Daniel,

    Please replace the following line:

    
    $url = trailingslashit( trailingslashit( bp_get_members_directory_permalink() ) . 'me/' . bp_get_members_invitations_slug() );
    

    with

    
    $url = trailingslashit( bp_loggedin_user_domain() );
    
    

    Give it a try.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 741
    Tosin on #47362

    Thanks Brajesh my issue is now resolved

  • Keymaster
    (BuddyDev Team)
    Posts: 22213
    Brajesh Singh on #47364

    You are welcome!

You must be logged in to reply to this topic.

This topic is: resolved