Skip to content

Commit 9756a03

Browse files
subscriberUpdateAttributesMultiple
1 parent 4db4361 commit 9756a03

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

plugins/restapi/includes/subscribers.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,4 +614,40 @@ public static function subscriberAddHistory()
614614
Response::outputError($e);
615615
}
616616
}
617+
618+
619+
620+
621+
/** Update attributes to a subscriber
622+
*
623+
* <p><strong>Parameters:</strong><br/>
624+
* [*userid] {integer} the ID of the Subscriber.<br/>
625+
* [*attributes] {array} list of attributes pairs to update [{"attributeid": value}].<br/>
626+
* </p>
627+
* <p><strong>Returns:</strong><br/>
628+
* Return all attributes of userid, be updated or not.
629+
* </p>
630+
*/
631+
public static function subscriberUpdateAttributesMultiple($userid=0, $attributes=array()) {
632+
if($userid == 0){
633+
$userid = $_REQUEST['userid'];
634+
}
635+
636+
if(count($attributes) == 0){
637+
// $_REQUEST['attributes'] is a JSON with slashes, it is necessary to decode it.
638+
$attributes = json_decode(stripslashes($_REQUEST['attributes']),true);
639+
}
640+
foreach($attributes as $attributes2){
641+
foreach($attributes2 as $attributeid=>$value){
642+
self::subscriberUpdateAttribute($userid, $attributeid, $value, true);
643+
}
644+
}
645+
$params = array(
646+
"userid" => array($userid, PDO::PARAM_INT)
647+
);
648+
649+
Common::select('Attribute', 'SELECT * FROM '.$GLOBALS['tables']['user_attribute']
650+
." WHERE userid=:userid;",$params, false);
651+
die(0);
652+
}
617653
}

0 commit comments

Comments
 (0)