• Resolved gbordormor22

    (@gbordormor22)


    Beautiful day to you Sir,

    Now, my website is a BuddyPress Community website.

    I want to show my users that they are loved and cared for.

    The way I want to do this, is to send them a Birthday Greeting on the day of their Birthday.

    How do I configure WP SMS to know how to track these Birthdays, and to send an SMS by 6am Local Time on the day of the user’s Birthday?

    Needing to hear from you soon.

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mostafa Soufi

    (@mostafas1990)

    Hello,

    Thank you for opening the topic this needs a custom cronjob to check the date from the database every day, but I’m thinking that might be a good feature to add this in WP SMS.

    However, if you are familiar with WordPress Event/Cronjob, you can register an event to do that like this

    function send_birthday_sms_greetings() {
        // Ensure this function only runs once a day
        if (get_transient('sent_birthday_sms_for_today')) {
            return;
        }
    
        $current_date = current_time('Y-m-d');
    
        // Query for users whose birthday is today
        $args = array(
            'meta_query' => array(
                array(
                    'key' => 'birthdate', // Replace with actual meta key for birthdate
                    'value' => $current_date,
                    'compare' => 'LIKE'
                ),
            ),
        );
        $users = get_users($args);
    
        // Send SMS to each user
        foreach ($users as $user) {
            $message = "Happy Birthday! We hope you have a fantastic day!";
            $phone_number = get_user_meta($user->ID, 'phone_number', true); // Replace with actual meta key for phone number
    
            if ($phone_number) {
                wp_sms_send($phone_number, $message); // Replace with actual function to send SMS
            }
        }
    
        // Set a transient to prevent the function from running again today
        set_transient('sent_birthday_sms_for_today', true, DAY_IN_SECONDS);
    }
    
    // Hook the function into WP-Cron
    if (!wp_next_scheduled('send_birthday_sms_greetings_hook')) {
        wp_schedule_event(strtotime('06:00:00'), 'daily', 'send_birthday_sms_greetings_hook');
    }
    
    add_action('send_birthday_sms_greetings_hook', 'send_birthday_sms_greetings');
    

    I haven’t tested it yet but need to be test.

    Thread Starter gbordormor22

    (@gbordormor22)

    Thank You very much Sir, for this reply. I really appreciate it.

    Here is my 1,000 hugs for your beautiful reply ????????????????????

    1.) I will need you to test the code first, for us to be sure that it works, before I add it to my functions.php file.

    I need you to be sure that this is a functional Code, so that it doesn’t crash my website.

    2.) You won my heart, when you agreed with me that this is a lovely feature to add to WP SMS.

    You see, I do get Birthday SMS from my Bank and my Pension Fund Managers, whenever it is my Birthday.

    So, it will be a very welcomed Idea if WP SMS can add this feature soon.

    Would you start the development of this feature into WP SMS soon?

    Regards.

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    Great to hear your positive feedback, thank you!

    Indeed, we are excited about the upcoming ‘WP SMS Automation’ add-on. This is a significant feature for us, and naturally, it requires some time to perfect. Our focus is on integrating an automated SMS system based on specific triggers, which will significantly streamline the process of sending texts to your audience. We’re committed to ensuring this feature enhances your experience efficiently and effectively.

    Best regards

    Thread Starter gbordormor22

    (@gbordormor22)

    With all that you have said in the long and short, will this “WP SMS Automation add-on” make it possible to send an Automated Birthday Message to my users on the day of their Birthday?

    Regards.

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    Yeah, it will be possible!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘send Birthday Greeting with WP-SMS’ is closed to new replies.