Skip to:
Content
Pages
Categories
Search
Top
Bottom

Customizing Buddypress Activation Emails (and still get activation key)

  • Avatar of kpolkson
    kpolkson
    Participant

    @kpolkson

    Hi,

    I have the following filters set up in my theme’s functions.php file to make a custom activation email for new users. Most everything works, but the only problem is the activation url does not pull trough the activation key, it’s just blank after ‘?key=’ what am I missing here to get the activation key (and avoid having to alter bp-core files):

    /*FILTERS FOR CUSTOM BUDDYPRESS ACTIVATION EMAIL*/

    function change_bp_activation_subject($subject) {

    $from_name = ( ” == get_site_option( ‘site_name’ ) ) ? ‘WordPress’ : esc_html( get_site_option( ‘site_name’ ) );

    return __( ‘Activate Your Account With Our Forums Today’, ‘buddypress’ );

    }

    add_filter(‘bp_core_activation_signup_user_notification_subject’, ‘change_bp_activation_subject’);

     

    function change_bp_activation_message($message) {

    $activate_url = bp_get_activation_page() . “?key=$key”;

    $activate_url = esc_url($activate_url);

    $email = is_admin() ? ‘&e=1′ : ”;

    return sprintf( __( “Greetings,\n\nYou have subscribed to our new community website. \n\n To complete the activation of your account and to set up a new password, please click the following link:\n\n%1\$s\n\n \Thanks for taking the time to complete your subscription!”, ‘buddypress’ ), $activate_url . $email );

    }

    add_filter(‘bp_core_activation_signup_user_notification_message’, ‘change_bp_activation_message’);

     

    /*END – CUSTOM BUDDYPRESS ACTIVATION EMAIL*/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Toby Cryns (@themightymo)
    Toby Cryns (@themightymo)
    Participant

    @themightymo

    @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 ) );`

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

    Avatar of kpolkson
    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!

    Avatar of Toby Cryns (@themightymo)
    Toby Cryns (@themightymo)
    Participant

    @themightymo

    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.

    Avatar of kpolkson
    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

    Avatar of becskr
    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’);
    `

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.