colindb (@colindb)

Forum Replies Created

Viewing 1 replies (of 1 total)
  • I don’t know how to write plug-ins, but I just installed bbPress and wanted to be able to approve new users. I messed around with the code just enough to get what I needed working, here are the changes I made:

    Starting with the function bb_send_pass function in bb-includes/registration-functions.php: I added an optional third parameters, so the function signature now looks like:

    function bb_send_pass( $user, $pass, $toAdmin = false ) {

    If the toAdmin flag is set I want this email to go to me, not the requesting user. So, just above the “$message = …” line, I added this:

    $recipient = bb_get_user_email( $user->ID );

    $rawRecipient = $recipient;

    if ($toAdmin)

    $recipient = 'myemail@example.com';

    I’m sure there is a better way to grab an administrator’s email, but like I said, I don’t know anything about bbPress… And what’s this about $rawRecipient? To make my life easier, I’m also including the email address in the email’s body (so I can forward it to the correct person without having to look up their info again). I did this by adding “Your email:” to the “$message = …” line:

    $message = __("Your username is: %1$s nYour password is: %2$s nYour email is: %4$s nYou can now log in: %3

    $s nnEnjoy!");

    And then including “$rawRecipient” as the 4th parameter to the sprintf call at the end of the function. Again, you could get fancy here (only include the email address if it’s going to an admin, for example), but whatever, this works. :)

    Okay, with that function done, we just need to change the registration code that calls it. I went to the bb_new_user function in bb-includes/pluggable.php. Just before that function returns there’s an “if ( defined (‘BB_INSTALLING’) )” check. The else case calls bb_send_pass (the function we just changed). Add a third parameter (sending ‘true’), and the registration code should now send an email to you instead of the newly registered user.

    As a final touch, I updated the registration success page (bb-templates/kakumei/register-success.php in my case), telling the user that an admin will verify their request and then email them.

    Hope this helps someone out.

Viewing 1 replies (of 1 total)