• Resolved marcusjwilson

    (@marcusjwilson)


    Hi Christian

    I think my question is partially answered here: https://github.com/christianwach/civicrm-wp-member-sync/issues/18#issuecomment-303952188

    When your plugin creates a WordPress user from a CiviCRM Member Contact record, the standard WordPress New User Registration email is not sent with email/password details. Is that correct?

    If so, what’s the best way to hook in to your plugin to trigger the notification email action in WP? I’m assuming the wp_new_user_notification function could be used, assuming we can pass the right values of the new user?

    Would something like this work?

    add_action( 'civi_wp_member_sync_after_insert_user', 'cp_trigger_user_notification' );
    function cp_trigger_user_notification( $civi_contact, $user_id ) {
      wp_new_user_notification( $user_id, null, 'both' );
    }

    Any pointers gratefully received!

    Best wishes
    Marcus

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter marcusjwilson

    (@marcusjwilson)

    Hmm… Failed. My proposed code above resulted in no emails at all being triggered on CiviCRM Member sync creation of the WP user.

    Plugin Author Christian Wach

    (@needle)

    @marcusjwilson I think you forgot to specify the param count in your add_action declaration:

    add_action( 'civi_wp_member_sync_after_insert_user', 'cp_trigger_user_notification', 10, 2 );
    function cp_trigger_user_notification( $civi_contact, $user_id ) {
      wp_new_user_notification( $user_id, null, 'both' );
    }
    

    Without the 10, 2 bit there’s no $user_id being received by the callback and therefore wp_new_user_notification() won’t send the emails.

    Thread Starter marcusjwilson

    (@marcusjwilson)

    Doh! You’re absolutely right, of course.

    Thanks so much, Christian – that appears to be working to trigger the correct email notifications now.

    m

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP Email notification: Email/Password’ is closed to new replies.