WordPress.org

Ready to get started?Download WordPress

Forums

Moderate Signup / Restrict Registration (WPMU & BP) (5 posts)

  1. zlamczyk
    Member
    Posted 3 years ago #

    WPMU 2.9.2
    BuddyPress 1.2.4

    I need admins to activate newly registered users, not the users themselves. I haven't been able to come up with a working plugin - probably because I've got MU and BuddyPress both running on my "members only" site.

    I've modified the bp-core-signup.php file to send an e-mail to the user without the activation link and added an e-mail to the admin e-mail with the activation url. However, the user still ends up with the only e-mail, and it contains the activation url. Furthermore, the e-mail comes from noreplay@ which means that WP thinks I don't have an admin e-mail set, which is not the case (I have one set).

    bp-core-signup.php (originally)

    function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
    	$activate_url = bp_get_activation_page() ."?key=$key";
    	$activate_url = clean_url( $activate_url );
    	$admin_email = get_site_option( "admin_email" );
    
    	if ( empty( $admin_email ) )
    		$admin_email = 'noreply@' . $_SERVER['SERVER_NAME'];
    
    	$from_name = ( '' == get_option( 'blogname' ) ) ? 'BuddyPress' : wp_specialchars( get_option( 'blogname' ) );
    	$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%s\n\n", 'buddypress' ), $activate_url );
    	$subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    
    	/* Send the message */
    	$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );
    	$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
    	$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
    
    	wp_mail( $to, $subject, $message, $message_headers );
    }

    bp-core-signup.php (my modification, not working)

    function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
    	$activate_url = bp_get_activation_page() ."?key=$key";
    	$activate_url = clean_url( $activate_url );
    	$admin_email = get_site_option( "admin_email" );
    
    	if ( empty( $admin_email ) )
    		$admin_email = 'noreply@' . $_SERVER['SERVER_NAME'];
    
    /* START MOD */
    	$from_name = ( '' == get_option( 'blogname' ) ) ? 'BuddyPress' : wp_specialchars( get_option( 'blogname' ) );
    	$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! And admin will confirm your membership.\n\nYou will receive a separate e-mail after this confirmation.", 'buddypress' ), $activate_url );
    	$subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    
    	/* Send the message */
    	$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );
    	$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
    	$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
    
    	wp_mail( $to, $subject, $message, $message_headers );
    /* END MOD */
    
    /* START ADD */
    	$from_name = ( '' == get_option( 'blogname' ) ) ? 'BuddyPress' : wp_specialchars( get_option( 'blogname' ) );
    	$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( __( "New registration request from\n\nUsername: %s\n\nE-mail: %s\n\nPlease confirm by clicking the link below:\n\n%s\n\n", 'buddypress' ), $user_id, $user_email, $activate_url );
    	$subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    
    	/* Send the message */
    	$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $admin_email );
    	$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
    	$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
    
    	wp_mail( $to, $subject, $message, $message_headers );
    /* END ADD */
    }

    So, after I submit a test registration, I get an with the information below:

    from Members Only <noreply@domain.net>
    to user@domain.com
    date Thu, Jun 3, 2010 at 3:42 AM
    subject [Members Only] Activate Your Account

    hide details 3:42 AM (3 minutes ago)

    Thanks for registering! To complete the activation of your account please click the following link:

    http://members.domain.net/activate?key=xxxxxxxxxxxxxxxx

    Could someone help me by directing me to a plugin or some way to change my code so that I'm able to restrict registration to admin approval?

  2. zlamczyk
    Member
    Posted 3 years ago #

  3. zlamczyk
    Member
    Posted 3 years ago #

  4. zlamczyk
    Member
    Posted 3 years ago #

  5. zlamczyk
    Member
    Posted 3 years ago #

    Figured this out, finally. Turns out that the file and function to modify was:
    wp-content\plugins\buddypress\bp-core\bp-core-filters.php
    -->function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta )

    Isn't it redundant to have two functions so similar to each other? Both the above function and
    wp-content\plugins\buddypress\bp-core\bp-core-signup.php
    -->function bp_core_signup_send_validation_email( $user_id, $user_email, $key )
    are extraordinarily similar to each other. It's kinda frustrating.

    I'd consider developing a plugin, but perhaps I'll wait for the first release of WP 3.0.

Topic Closed

This topic has been closed to new replies.

About this Topic