Skip to:
Content
Pages
Categories
Search
Top
Bottom

Customizing Buddypress Activation Emails (and still get activation key)

Viewing 7 replies - 1 through 7 (of 7 total)
  • @kpolkson,
    There are smarter people around these forums than me, but I will try to help.

    It looks like you haven’t defined the $key variable or have not passed it properly.

    Perhaps try digging into bp-members-functions.php and figuring out a way to extract the $key variable. See the line:
    `$user_id = $wpdb->get_var( $wpdb->prepare( “SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = ‘activation_key’ AND meta_value = %s”, $key ) );`

    https://buddypress.svn.wordpress.org/trunk/bp-members/bp-members-functions.php


    kpolkson
    Participant

    @kpolkson

    hmm, good point. though it seems to me that the query there is assuming a key has already been generated and is associated with a user in the db. The email goes to brand new users that haven’t activated yet, so not sure where to step into the actual $key generation process. I’ll dig around further.

     

    thanks!

    One other thing that I don’t know the answer to is how BuddyPress keys are connected to the WordPress registration process. For example, does WordPress generate the key, or is it BuddyPress that is generating the key?

    If WordPress is generating the key, then the answer might be further down the line.


    kpolkson
    Participant

    @kpolkson

    you’re probably right.

    Though I’d be curious to hear from any of the buddypress experts (or maybe just wordpress experts in general – I am not a big php or wordpress guy) how it is that the function for the activation emails is pulling in the $key where it does not appear to be defined or set up anywhere in the bp-core-filters.php file*, it just appears and is handled as such. I assumed if the filter were set up to attach to that function, it would pull in whatever that function pulls in it’s original context.

    *http://openlab.citytech.cuny.edu/redmine/projects/openlab/repository/revisions/028e8c7af06906d09b18f01fdee8951bf076c0ec/entry/wp-content/plugins/buddypress/bp-core/bp-core-filters.php


    becskr
    Participant

    @becskr

    I know this is old but I had the same problem and figured out how to fix it so thought I would post it.
    Instead of trying to feed the key in, I just trimmed the message to remove the original wording and then replaced it with my own wording.

    `
    function fix_bp_activation_message($message) {
    $msgTrim = “Thanks for registering! To complete the activation of your account please click the following link:”;
    $trimmed = trim($message,$msgTrim);

    return __( “Thanks for signing up to Clandestine Cake Club! In order to take part in the fun, you’ll need to activate your account by clicking the link below. \n Once you’ve done that, we’ll need to approve the account, usually within 24 hours.”.$trimmed.”Best wishes,\n Lynn Hill – CCC Founder”, ‘buddypress’ );
    }

    add_filter(‘bp_core_signup_send_validation_email_message’, ‘fix_bp_activation_message’);
    `


    gentlemanhog
    Participant

    @gentlemanhog

    Hi,

    I did this, after some digging into the $bp object after the registration form is posted. Not tested properly in the wild yet, so you might want to double check before using this. Done via WordPress 3.5.1 and BuddyPress 1.7.2.

    
    add_filter('bp_core_signup_send_validation_email_message', 'custom_bp_change_activation_email_message');
    function custom_bp_change_activation_email_message($message) {
    	//	Get some globals
    	global $bp, $wpdb;
    
    	//	Get the slug of the activation page
    	$slug = $bp->pages->{"activate"}->slug;
    
    	//	Get username from the signup form just posted
    	$username = $bp->signup->username;
    
    	//	SQL query to get activation key for that username
    	$sql = 'select meta_value from wp_usermeta where meta_key="activation_key" and user_id in (select ID from wp_users where user_login="' . $username . '" and user_status=2)';
    
    	//	Getting the activation key from the database
    	$activation_key = $wpdb->get_var($sql);
    
    	//	Make activation URL
    	$url = sprintf("%s/%s/?key=%s", WP_HOME, $slug, $activation_key);
    
    	//	Custom message with activation key
    	$message = "Yayy! Thanks for signing up! Please confirm your account!\n\n$url";
    
    	return $message;
    }
    

    I’ve got this in a theme’s functions.php file, but not sure if that’s the right place for it. Would it be better in bp_custom.php?

    Ta,
    Alan.

    @gentlemanhog – If it works, then it doesn’t matter where it is. 🙂

    The conventional wisdom is to keep things out of functions.php unless they are theme-specific. In your case, I would say this function belongs someplace other than the theme’s functions.php file.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Customizing Buddypress Activation Emails (and still get activation key)’ is closed to new replies.
Skip to toolbar