Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirect after AJAX upload avatar (Drag & Drop)


  • CatchThePigeon
    Participant

    @catchthepigeon

    WP Version 4.6.1
    BP Version 2.7.0
    URL – localhost testing (pre-live update)

    Have recently updated my WP & BP setup and on running tests have found the code to redirect to a location after avatar upload no longer works. With the xprofile_avatar_uploaded hook active it doesn’t even refresh the avatar after successful change.

    The uploader now appears to use AJAX and so once the process is completed the user remains on the avatar page.

    Is there any way to go back to a non AJAX version of the upload to allow the filtered redirect or a callback script I can use to trigger a window.location when completed?

Viewing 1 replies (of 1 total)

  • CatchThePigeon
    Participant

    @catchthepigeon

    To answer my own question for someone elses reference:

    After following the event listeners back to avatar.min.js I found the regular avatar.js which says the following:

    * Set the Attachment object
    *
    * You can run extra actions once the avatar is set using:
    * bp.Avatar.Attachment.on( ‘change:url’, function( data ) { your code } );
    *
    * In this case data.attributes will include the url to the newly
    * uploaded avatar, the object and the item_id concerned.

    So the following code will achieve the desired result:

    $(window).load(function() {
                   bp.Avatar.Attachment.on( 'change:url', function( data ) {
                                           window.location.replace("/URL-GOES-HERE/");
                                           } );
                   });
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar