我希望这样的事情能奏效

http://en.gravatar.com/site/signup?email=user%40example.com

为了避免用户不得不重新输入电子邮件。

最佳答案

我注意到this wordpress package为用户处理了它(以及其他大量内容),因此我仔细研究了他的代码,然后他使用了以下PHP函数:

/**
 * Get URL to locale gravatar signup page
 *
 * @since 2.0
 * @param string $email Email address that should be apended
 * @return string $gse_url URL of locale signup page
 */
function gravatar_signup_encouragement_locale_signup_url( $email = '' ) {
    /* translators: Locale gravatar.com, e.g. sr.gravatar.com for Serbian */
    $gse_locale_url = _x( 'en.gravatar.com', 'Locale gravatar.com, e.g. sr.gravatar.com for Serbian', 'gse_textdomain' );

    /* Check if it's really locale.gravatar.com */
    if ( preg_match( '|^[A-Z_%+-]+.gravatar+.com|i', $gse_locale_url ) ) {
        $gse_locale_url = $gse_locale_url;
    } else {
        $gse_locale_url = 'en.gravatar.com';
    }

    /* If email exists, append it */
    if ( empty( $email ) ) {
        $gse_url = "http://" . $gse_locale_url . '/site/signup/';
    } else {
        $encoded_email = urlencode( $email );
        $gse_url = "http://" . $gse_locale_url . '/site/signup/' . $encoded_email;
    }

    return $gse_url;
}

不幸的是,由于Wordpress用oauth帐户接管了表单,因此这可能不再起作用,所以这是我的Ruby on Rails转换解决方案。重要的一点是HTTP参数user_email存在并起作用:
  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

我不确定所有其他重定向参数,因为随着Wordpress接管Gravatar的方式,这些重定向参数可能会随着时间而改变,但希望这能使您朝正确的方向发展。

关于gravatar - 是否有Gravatar注册链接来预填充用户的电子邮件地址?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7371690/

10-10 02:50