Plugin Directory

Changeset 2320543


Ignore:
Timestamp:
06/09/2020 02:02:43 AM (6 years ago)
Author:
brewlabs
Message:

Add new function

Location:
sendpress/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sendpress/trunk/classes/class-sendpress-data.php

    r2247605 r2320543  
    15731573
    15741574
     1575    static function subscribe_user_to_lists($userarray , $list_ids, $status=2,$custom=array()){
     1576        $defaults = array(
     1577            'firstname'           => '',
     1578            'lastname'          => '',
     1579            'email' => '',
     1580            'phonenumber'            => '',
     1581            'salutation'          => ''
     1582        );
     1583        $userarray = wp_parse_args( $userarray, $defaults );
     1584        $success = false;
     1585        $subscriberID = SendPress_Data::add_subscriber($userarray);
     1586        if( false === $subscriberID ){
     1587            return false;
     1588        }
     1589
     1590        $args = array(
     1591            'post_type' => 'sendpress_list',
     1592            'numberposts'  => -1,
     1593            'offset'          => 0,
     1594            'orderby'         => 'post_title',
     1595            'order'           => 'DESC'
     1596        );
     1597
     1598        $lists = get_posts( $args );
     1599
     1600        $listids = explode(',', $list_ids);
     1601
     1602        $already_subscribed = false;
     1603
     1604        foreach($lists as $list){
     1605            if( in_array($list->ID, $listids) ){
     1606                $current_status = SendPress_Data::get_subscriber_list_status( $list->ID, $subscriberID );
     1607                SendPress_Error::log($current_status);
     1608                if( empty($current_status) || ( isset($current_status->status) && $current_status->status < 2 ) ){
     1609                    $success = SendPress_Data::update_subscriber_status($list->ID, $subscriberID, $status);
     1610                } else {
     1611                    $success = true;
     1612                }
     1613                if(isset($custom) && is_array($custom) && !empty($custom)){
     1614                    foreach ($custom as $key => $value) {
     1615                        SendPress_Data::update_subscriber_meta( $subscriberID, $key, $value, $list->ID );
     1616                    }
     1617                }
     1618
     1619            }
     1620        }
     1621
     1622        if($success == false){
     1623            return false;
     1624        }
     1625
     1626        return array('success'=> $success,'already'=> $already_subscribed);
     1627    }
     1628
     1629
     1630
     1631
     1632
    15751633    static function subscribe_user($listid, $email, $first, $last, $status = 2, $custom = array(), $phonenumber='', $salutation='') {
    15761634
  • sendpress/trunk/readme.txt

    r2282705 r2320543  
    55Requires at least: 4.4
    66Tested up to: 5.4
    7 Stable tag: 1.20.4.13
     7Stable tag: 1.20.6.08
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    119119Previous releases can be downloaded from [GitHub](https://github.com/brewlabs/sendpress/releases)
    120120
    121  1.20.4.13 - 2020.4.13 =
     121= 1.20.6.08 - 2020.6.08 =
     122* Add new subscribe function
     123
     124= 1.20.4.13 - 2020.4.13 =
    122125* fix issue with extra log data in logs
    123126
    124  1.20.3.19 - 2020.3.19 =
     127= 1.20.3.19 - 2020.3.19 =
    125128* fix issue with admin area redirect
    126129
  • sendpress/trunk/sendpress.php

    r2282705 r2320543  
    22/*
    33Plugin Name: SendPress Newsletters
    4 Version: 1.20.4.13
     4Version: 1.20.6.08
    55Plugin URI: https://sendpress.com
    66Description: Easy to manage Newsletters for WordPress.
     
    2020define( 'SENDPRESS_API_VERSION', 1 );
    2121define( 'SENDPRESS_MINIMUM_WP_VERSION', '3.6' );
    22 define( 'SENDPRESS_VERSION', '1.20.4.13' );
     22define( 'SENDPRESS_VERSION', '1.20.6.08' );
    2323define( 'SENDPRESS_URL', plugin_dir_url( __FILE__ ) );
    2424define( 'SENDPRESS_PATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.