Convert entries form to subscribers after submitting new from in Contact Form 7

Sometimes you’d like to store your contacts data in the WP-SMS newsletter, so here is a simple function that helps you to do that.

/**
 * @param WPCF7_Submission $WPCF7_Submission
 */
function addNumberToSubscriberList(WPCF7_Submission $WPCF7_Submission)
{
    $data   = $WPCF7_Submission->get_posted_data();
    $name   = isset($data['your-name']) ? $data['your-name'] : "";
    $mobile = isset($data['your-mobile']) ? $data['your-mo'] : "";

    \WP_SMS\Newsletter::addSubscriber($name, $mobile, 'group-id', '1');
}

add_action('wpcf7_before_send_mail', 'addNumberToSubscriberList');