BuddyPress-将新用户激活链接发送给管理员

时间:2012-08-05 作者:Androliyah

如何将新用户激活链接发送到我自己的电子邮件地址而不是用户?有没有一个简单的函数可以用来切换东西?

function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {

$activate_url = bp_get_activation_page() . "?key=$key";
$activate_url = esc_url($activate_url);
$admin_email  = get_site_option( \'admin_email\' );

if ( empty( $admin_email ) )
    $admin_email = \'support@\' . $_SERVER[\'SERVER_NAME\'];

// If this is an admin generated activation, add a param to email the
// user login details
$email = is_admin() ? \'&e=1\' : \'\';

$from_name       = ( \'\' == get_site_option( \'site_name\' ) ) ? \'WordPress\' : esc_html( get_site_option( \'site_name\' ) );
$message_headers = "MIME-Version: 1.0\\n" . "From: \\"{$from_name}\\" <{$admin_email}>\\n" . "Content-Type: text/plain; charset=\\"" . get_option( \'blog_charset\' ) . "\\"\\n";
$message         = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\\n\\n%1\\$s\\n\\n", \'buddypress\' ), $activate_url . $email );
$subject         = \'[\' . $from_name . \'] \' . __( \'Activate Your Account\', \'buddypress\' );

// Send the message
$to      = apply_filters( \'bp_core_activation_signup_user_notification_to\',   $user_email, $user, $user_email, $key, $meta );
$subject = apply_filters( \'bp_core_activation_signup_user_notification_subject\', $subject, $user, $user_email, $key, $meta );
$message = apply_filters( \'bp_core_activation_signup_user_notification_message\', $message, $user, $user_email, $key, $meta );

wp_mail( $to, $subject, $message, $message_headers );

do_action( \'bp_core_sent_user_signup_email\', $admin_email, $subject, $message, $user, $user_email, $key, $meta );

// Return false to stop the original WPMU function from continuing
return false;
}如果(!is\\u admin()| |(is\\u admin()&&;空($\\u POST[\'noconfirmation\']))添加筛选器(\'wpmu\\u signup\\u user\\u notification\',\'bp\\u core\\u activation\\u signup\\u user\\u notification\',1,4);

1 个回复
最合适的回答,由SO网友:fuxia 整理而成

阅读代码时,我会尝试以下方法:

add_filter( 
    \'bp_core_signup_send_validation_email_to\', 
    \'wpse_60858_catch_user_signup_mail\' 
);

function wpse_60858_catch_user_signup_mail()
{
    // make sure to use a valid email. test it with different addresses
    return get_site_option( \'admin_email\', \'[email protected]\' );
}
这将改变$to 仅零件。

结束

相关推荐

为每个BuddyPress用户添加一个WooCommerce商店

我正在与buddypress和woocommerce创建一个社交网站。我想让每个会员都能从其他人那里购买并在线销售他们的产品。也就是说,每个用户在注册时都必须分配到woo commerce类别,他们的产品将列在类别的子类别中。对于每个类别,都应该有一个单独的支付帐户(如贝宝)。我想在不使用buddypress多站点功能的情况下实现这一点。我追求的是:我想要一个背后的想法,任何代码片段、示例或插件。欢迎所有答案和建议。提前谢谢。