The MU forums have moved to WordPress.org

Moderate Signup / Restrict Registration (8 posts)

  1. zlamczyk
    Member
    Posted 10 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. andrea_r
    Moderator
    Posted 10 years ago #

    Have you asked over at the BuddyPress forums? the reason I mention it is because all the above is bp-specific.

  3. zlamczyk
    Member
    Posted 10 years ago #

    Not yet.

    I've posted here, partly because I read something (and honestly, I think it may have been by you on a different site) about modifying wpmu-functions.php and wp-signup.php in order to restrict both blog and user creation. And now, I cannot find that page...

    Well, I also tried modifying both of those files as described and it did not work for me. That's when I tried modifying the BP files, too.

    In the end, I wasn't sure if this was a WPMU or a BuddyPress issue.

  4. andrea_r
    Moderator
    Posted 10 years ago #

    Yeah, that was my tute. :) But it was before BuddyPress, and BP has it's own registration system. It hijacks the regular one and inserts its own stuff.

  5. zlamczyk
    Member
    Posted 10 years ago #

    Alright.

    Guess I'll head over to their forums once again....

  6. zlamczyk
    Member
    Posted 10 years ago #

  7. zlamczyk
    Member
    Posted 10 years ago #

    Anyone from WPMU side have an idea how to get WPMU + BuddyPress activation e-mails to be sent to admin(s) instead of the corresponding user?

    I want admins to moderate user registration activation as simply as possible. Hence, admins receiving the user activation e-mail and easily choosing to click the user's activation url - or not to disallow.

    So really, what I need is a plugin or hack for WPMU 2.9.2 and BP 1.2.4 that:

    1. Sends user registration activation e-mails to admin(s)
    2. Gives admin(s) option to approve user registration
    3. Gives admin(s) option to reject user registration, allowing username to be recycled immediately
  8. zlamczyk
    Member
    Posted 10 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.

About this Topic

  • Started 10 years ago by zlamczyk
  • Latest reply from zlamczyk