Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom BuddyPress email not always sending


  • bcanr2d2
    Participant

    @bcanr2d2

    I currently have an issue with trying to get a custom email to send once a user activates.

    When a user does a traditional signup/activation, the email gets sent without any issues.
    But when I use plugin to do sign ups via social media, this email does not get sent, and I get the following error when I capture the results of the failed email message.

    object(WP_Error)#6355 (2) { ["errors"]=> array(1) { ["missing_email"]=> array(1) { [0]=> string(12) "bp_get_email" } } ["error_data"]=> array(1) { ["missing_email"]=> array(2) { [0]=> string(24) "member_activated_account" [1]=> array(6) { ["no_found_rows"]=> bool(true) ["numberposts"]=> int(1) ["post_status"]=> string(7) "publish" ["post_type"]=> string(8) "bp-email" ["suppress_filters"]=> bool(false) ["tax_query"]=> array(1) { [0]=> array(3) { ["field"]=> string(4) "slug" ["taxonomy"]=> string(13) "bp-email-type" ["terms"]=> string(24) "member_activated_account" } } } } } }

    My code for the custom email creation, and the code to call it is as follows:

    function welcome_email_message() {
     
        // Do not create if it already exists and is not in the trash
        $post_exists = post_exists( '[{{{site.name}}}] Welcome to {{{site.name}}}' );
     
        if ( $post_exists != 0 && get_post_status( $post_exists ) == 'publish' )
           return;
      
        // Create post object
        $my_post = array(
          'post_title'    => __( '[{{{site.name}}}] Welcome to {{{site.name}}}', 'buddypress' ),
          'post_content'  => __( 'Hi {{recipient.name}}, welcome  to {{site.name}}! Thankyou for signing up and helping us grow our community.
    
    {{site.name}} is a community run service which connects families with the right babysitter or nanny for them.
    
    Your new account is all set up and ready to go, you can login with the following information:
    
    Username: <strong>{{recipient.username}}</strong>
    This link will take you to our log in page:
    <a href="https://bbs4you.com/login/?login=newuser">Login</a>
    
    We need you to log in and fill in the details of your profile in order to make the most of our site.
    
    Please let us know if you have any issues using the site via the contact us page:
    <a href="https://bbs4you.com/contact-us/">Contact Us</a>
    
    The {{site.name}} Team', 'buddypress' ),  // HTML email content.
          'post_excerpt'  => __( 'Hi {{recipient.firstname}}, welcome  to {{site.name}}! Thankyou for signing up and helping us grow our community.
    
    {{site.name}} is a community run service which connects families with the right babysitter or nanny for them.
    
    Your new account is all set up and ready to go, you can login with the following information:
    
    Username: {{recipient.username}}
    
    This link will take you to our log in page:
    
    Login
    We need you to log in and fill in the details of your profile in order to make the most of our site. Please let us know if you have any issues using the site via the contact us page:
    Contact Us
    The {{site.name}} Team.', 'buddypress' ), // Plain text email content. 'post_status' => 'publish', 'post_type' => bp_get_email_post_type() // this is the post type for emails ); // Insert the email post into the database $post_id = wp_insert_post( $my_post ); if ( $post_id ) { // add our email to the taxonomy term 'post_received_comment' // Email is a custom post type, therefore use wp_set_object_terms $tt_ids = wp_set_object_terms( $post_id, 'member_activated_account', bp_get_email_tax_type() ); foreach ( $tt_ids as $tt_id ) { $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() ); wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array( 'description' => 'A member activates their account', ) ); } } } add_action( 'bp_core_install_emails', 'welcome_email_message' ); function new_member_welcome_email( $user_id, $key = false, $user = false ) { if ( $user_id) { // get the user data $user = get_userdata( $user_id ); // add tokens to parse in email $args = array( 'tokens' => array( 'site.name' => get_bloginfo( 'name' ), 'recipient.firstname' => ucfirst($user->first_name), 'recipient.username' => $user->user_login, ), ); // send args and user ID to receive email bp_send_email( 'member_activated_account', $user_id, $args ); } } add_action( 'bp_core_activated_user','new_member_welcome_email', 99, 2 );

    Why it works for a normal activation, and not with a OneAll social login account creation seems to confuse me, as the user_id is set and coming through from this point.

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

  • ripulkr
    Participant

    @ripulkr

    Question : Are you using any custom plugin for Emails which may be modifying the wp_mail ?

    BuddyPress uses the wp_mail function but it also checks if any filter is modifying the wp_mail like converting the mail format from standard text to html. If BuddyPress detects that some plugin is modifying the wp_mail’s default behaviour then it would not run as it assumes that the mail is being taken care of by other plugin.


    bcanr2d2
    Participant

    @bcanr2d2

    I am using WP Mail SMTP to get the mail to send without issues. But it seems to affect this particular email only, I am getting everything else as far as I am aware.

    Here are my current active plugins – There is quite a long list.
    I do use Autoptimize, so not sure if it’s affecting anything.
    One of note, is Social Login, which when logging directs to their site, and redirects back to my site to log the user in via their social network, this is where it falls over and does not send this one email. It manages to send other emails related to the login, but it now gives me an idea to look into the code that sends this social email sign up notification.

    (BuddyDev) BP Auto Login on Activation (1.0.3)
    Advanced Custom Fields (4.4.11)
    Allow Multiple Accounts (3.0.4)
    Autoptimize (2.2.2)
    BP Profile Message UX Free (1.5)
    BP xProfile Location (1.2)
    BP XProfile WordPress User Sync (0.6.4)
    BuddyDev Username Availability Checker (1.1.1)
    BuddyExtender (1.0.1)
    BuddyPress (2.7.4)
    BuddyPress Member Type Generator (1.0.3)
    BuddyPress Security Check (2.1.2)
    BuddyPress Simple Terms And Conditions (1.3)
    BuddyPress Xprofile Custom Fields Type (2.6.3)
    BuddyPress Xprofile Member Type Field (1.0.4)
    BuddyPress XProfile Validate with RegEx (0.1.2)
    Cherry Parallax Plugin (1.1.0)
    Cherry Plugin (1.2.8.1)
    Child Theme Configurator (2.1.2)
    Conditional Profile Fields for BuddyPress (1.1.9)
    Contact Form 7 (4.6)
    Contact Form 7 – Dynamic Text Extension (2.0.1)
    Contact Form 7 Conditional Fields (1.0)
    Contact Form 7 Get and Show Parameter from URL (0.9.7)
    Contact Form 7 Honeypot (1.10)
    Contact Form 7 Modules: Hidden Fields (2.0)
    Contact Form 7 Shortcode Enabler (1.1)
    Custom Hooks (1.0)
    Custom Post Template By Templatic (1.0)
    Custom Post Type UI (1.4.3)
    Disable Comments (1.6)
    Display Posts Shortcode (2.7.0)
    FacetWP (2.7.4)
    FacetWP – Map (1.0.5)
    Flamingo (1.5)
    GeoIP Detection (2.7.0)
    GEO my WP (2.7)
    Google Analytics Dashboard for WP (4.9.6.2)
    List Plugins (1.4.4)
    Meta Slider (3.4)
    Optimize Database after Deleting Revisions (4.2.1)
    Page-list (5.1)
    PHP Compatibility Checker (1.4.0)
    Popup Maker (1.4.20)
    Shortcodes in Menus (3.2)
    Social Login (5.2)
    Stream (3.2.0)
    String Locator (2.2.0)
    Sucuri Security – Auditing, Malware Scanner and Hardening (1.8.3)
    SuitePlugins – Advanced XProfile Fields for BuddyPress (1.0.3)
    Theme Check (20160523.1)
    Visual Builder for Contact Form 7 (2.0)
    WPFront User Role Editor (2.13)
    WP Mail SMTP (0.11.1)
    WP Private Content Plus (1.13.1)
    WP Smush (2.6.1)
    Yoast SEO (4.3)


    bcanr2d2
    Participant

    @bcanr2d2

    Sorry for the double post, but am I able to disable the check for wp_mail changes, so it can go through without any hassle.


    denniosgwanka
    Participant

    @denniosgwanka

    Email should work but much can go wrong including things connected to plugins, themes and functions.php or bp-custom.php files.

    Presuming the email didn’t go into spam, and WordPress sent emails before installing BuddyPress, then one thing that can be tried is disabling all plugins except except buddypress and the ( un-customised ) bp-default theme.

    If this is a localhost/dev site then php / server has to be correctly configured and/or upgraded for email. Alternatively WP Mail SMTP may be useful in this situation…

    The main email address is set on the wordpress Settings > General page.
    I would advise you check you have correct PTR record for your IP address, and also set a SPF record along with your MX records doing these two things can drastically affect how mail servers receive your mail or reject it if not happy these two items exist and check out as valid.
    There may be other issues in some situations. For more info see: WordPress Not Sending Email – Mail SMTP Not Working

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar