How to Automatically Update Your Credit After Sending SMS

Updated on May 20, 2023

If you’re using the WP SMS plugin in WordPress to send SMS messages to your subscribers or customers, it’s important to keep track of your credit balance to ensure that you don’t run out of credit when you need it the most. In this tutorial, we’ll show you how to automatically update your credit after sending an SMS using a simple code snippet.

Step 1: Open your functions.php file

First, you need to open the functions.php file in your WordPress theme folder. This file is responsible for adding custom code to your WordPress website.

Step 2: Add the Code Snippet

Next, you need to add the following code snippet to the bottom of your functions.php file:

add_action('wp_sms_send', function () {
    \WP_SMS\Gateway::credit();
});

This code uses the add_action function to hook into the wp_sms_send event, which is triggered every time an SMS message is sent using the WP SMS plugin. When this event is triggered, the \WP_SMS\Gateway::credit() function is called, which updates your credit balance.

Step 3: Save Your Changes

Once you’ve added the code snippet to your functions.php file, you need to save your changes.

That’s it! You’ve successfully set up your WordPress website to automatically update your credit after sending an SMS using the WP SMS plugin.