I want to put this under "change picture" action url on the user profile. To limit possible mistakes, I would like to provide an email user used in the profile (thus used in the picture url) so they wouldn't have to while registering to Gr开发者_如何转开发avatar service.
I wonder if there is a way to generate an URL to a change/register Gravatar picture with email already provided.
Since no better answer was provided here my workaround:
<form action="http://pl.gravatar.com/accounts/signup" method="post">
<input type="hidden" name="email" value="name@example.com">
<input type="hidden" name="commit" value="Get Your Gravatar">
<button type="submit">Change avatar</button>
</form>
Here is my solution, since this link is often inside another form:
def gravatar_create_url(user)
user_email = u user.email.downcase
"https://signup.wordpress.com/signup/?ref=oauth2&user_email=#{user_email}&oauth2_redirect=bf551c93d83b96478db51481a9cbe97e%40https%3A%2F%2Fpublic-api.wordpress.com%2Foauth2%2Fauthorize%2F%3Fclient_id%3D1854%26response_type%3Dcode%26blog_id%3D0%26state%3D331f9ecba5fcab15e2168e1231f7be2a4b1b8cd24dd6f90b3672fb5159d7b590%26redirect_uri%3Dhttps%253A%252F%252Fen.gravatar.com%252Fconnect%252F%253Faction%253Drequest_access_token%26jetpack-code%26jetpack-user-id%3D0%26action%3Doauth2-login&wpcom_connect=1"
end
Notice the user_email variable in the query string. I'm not sure about all those other redirect params, as those may change over time with how Wordpress has taken over Gravatar, but hopefully this gets you in the right direction.
精彩评论