I’m assuming this is for the [avatar_upload] shortcode and not for the admin user profile. This snippet should do it:
wp.media.wpUserAvatar.frame().state('library').on('select', function() {
jQuery('.wpua-edit input[type="submit"]').click();
});
Hi Daniel,
Yes, I should have been more specific, from the [avatar_upload] shortcode. I will give that a try and report back, thanks so much!
Hi Daniel,
Well that worked like a charm. Thanks so much for that snippet! However I have one more related issue.
The select button submits the form just fine, however it doesn’t automatically update the image. In order to get the image to actually show up on the profile, I have to do the following:
1) Reload the page, (via the reload page button in FF) which produces a 400 bad request error.
2) Visit another page on the site
3) Re-visit the profile page
…New image shows up. Obviously not ideal.
Since .click functions don’t have a callback function associated with them, I’m not able to stick the reload command in a callback, so have experimented with the following:
wp.media.wpUserAvatar.frame().state('library').on('select', function() {
jQuery('#wpua-edit-1 input[type="submit"]').click();
setTimeout(location.reload(), 1000);
});
however this interferes with the form being submitted. I’ve also tried breaking out the reload command into a separate function like so.
wp.media.wpUserAvatar.frame().state('library').on('select', function() {
jQuery('#wpua-edit-1 input[type="submit"]').click();
reloadPage();
});
}
});
function reloadPage() {
setTimeout(location.reload(), 1000);
}
…Still no good, database doesn’t seem to get updated with new image. So if you have any thoughts on what I’m missing here to be able to reload the page so the user can see the new image on their profile page immediately, I’m all ears 🙂
Thanks Daniel!
The page should reload when the form is submitted. If it doesn’t it’s because another plugin or the theme is interfering with its behavior. Is there a link I can look at?
Hi Daniel,
Yes, I can supply you with a link, however as the page this is on is a user profile page, and only logged in users would actually see this page, I’ll need to setup a test account for you to try out.
I’d prefer not to share that info via a public forum, is there an email address I can reach you at?
thanks,
~Nick
You can send me a private message here. Please also reply to this topic once you do because messages through that contact form sometimes land in the spam folder. Thanks
@loxx927 Please don’t offer to send or post logon credentials on these forums:
https://ww.wp.xz.cn/support/guidelines#the-bad-stuff
You can contact the author on their own site and, once there, the discussion is between the two of you. However, it is not OK to enter or send site credentials on these forums. We don’t want to encourage others (who are less reputable) to do similar things. It’s a fine line, but one that we need to enforce. Thanks for your cooperation.
Hi Daniel,
I just sent you a detailed email via the above site. Thanks so much for your help!
@sterndata
Hi Steven,
I had no intention of doing that, hence why I was asking for an alternate method of contacting Daniel, but I appreciate that you guys are watching out for us. 🙂
We just don’t want the practice normalized.
@loxx927 I’m afraid your email didn’t go through. I checked all the folders. Can you send it again please? Alternatively you can message me on Facebook.