Skip to content

Commit 1c1703e

Browse files
committed
Merge remote-tracking branch 'origin/master'
Conflicts: controllers/User.php json-api-user.php readme.md
2 parents 7922dfc + 5c6af19 commit 1c1703e

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

controllers/User.php

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ public function get_user_meta() {
488488

489489
$meta_key = sanitize_text_field($json_api->query->meta_key);
490490

491+
<<<<<<< HEAD
491492

492493
if($meta_key) $data[$meta_key] = get_user_meta( $user_id, $meta_key);
493494
else {
@@ -604,6 +605,111 @@ public function xprofile() {
604605

605606

606607
}
608+
=======
609+
610+
if($meta_key) $data[$meta_key] = get_user_meta( $user_id, $meta_key);
611+
else $data = get_user_meta( $user_id);
612+
//d($data);
613+
return $data;
614+
615+
616+
}
617+
618+
public function update_user_meta() {
619+
620+
global $json_api;
621+
622+
if (!$json_api->query->cookie) {
623+
$json_api->error("You must include a 'cookie' var in your request. Use the `generate_auth_cookie` method.");
624+
}
625+
626+
$user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');
627+
628+
if (!$user_id) $json_api->error("Invalid cookie. Use the `generate_auth_cookie` method.");
629+
630+
631+
if (!$json_api->query->meta_key) $json_api->error("You must include a 'meta_key' var in your request.");
632+
633+
else $meta_key = $json_api->query->meta_key;
634+
635+
if (!$json_api->query->meta_value) {
636+
$json_api->error("You must include a 'meta_value' var in your request.");
637+
}
638+
else $meta_value = sanitize_text_field($json_api->query->meta_value);
639+
640+
641+
$data['updated'] = update_user_meta( $user_id, $meta_key, $meta_value);
642+
643+
644+
return $data;
645+
646+
}
647+
648+
public function delete_user_meta() {
649+
650+
global $json_api;
651+
652+
if (!$json_api->query->cookie) {
653+
$json_api->error("You must include a 'cookie' var in your request. Use the `generate_auth_cookie` method.");
654+
}
655+
656+
$user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');
657+
658+
if (!$user_id) $json_api->error("Invalid cookie. Use the `generate_auth_cookie` method.");
659+
660+
661+
if (!$json_api->query->meta_key) $json_api->error("You must include a 'meta_key' var in your request.");
662+
663+
else $meta_key = $json_api->query->meta_key;
664+
665+
if (!$json_api->query->meta_value) {
666+
$json_api->error("You must include a 'meta_value' var in your request.");
667+
}
668+
else $meta_value = sanitize_text_field($json_api->query->meta_value);
669+
670+
671+
$data['deleted'] = delete_user_meta( $user_id, $meta_key, $meta_value);
672+
673+
return $data;
674+
675+
}
676+
677+
public function xprofile() {
678+
679+
global $json_api;
680+
681+
if (function_exists('bp_is_active')) {
682+
683+
if (!$json_api->query->user_id) {
684+
$json_api->error("You must include a 'user_id' var in your request.");
685+
}
686+
else $user_id = $json_api->query->user_id;
687+
688+
689+
if (!$json_api->query->field) {
690+
$json_api->error("You must include a 'field' var in your request. Use 'field=default' for all default fields.");
691+
}
692+
elseif ($json_api->query->field=='default') {
693+
$field_label='First Name, Last Name, Bio';/*you should add your own field labels here for quick viewing*/
694+
}
695+
else $field_label = sanitize_text_field($json_api->query->field);
696+
697+
698+
$fields = explode(",", $field_label);
699+
700+
if(is_array($fields)){
701+
702+
foreach($fields as $k){
703+
704+
$fields_data[$k] = xprofile_get_field_data( $k, $user_id );
705+
706+
}
707+
708+
return $fields_data;
709+
710+
711+
}
712+
>>>>>>> origin/master
607713

608714
}
609715

json-api-user.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
99
Description: Extends the JSON API for RESTful user registration, authentication, password reset, Facebook Login, user meta and BuddyPress Profile related functions
1010
11+
<<<<<<< HEAD
1112
Version: 1.4
13+
=======
14+
Version: 1.3
15+
>>>>>>> origin/master
1216
1317
Author: Ali Qureshi
1418

readme.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ Tags: json api, RESTful user registration, authentication, RESTful Facebook Logi
66

77
Contributors: parorrey
88

9+
<<<<<<< HEAD
910
Stable tag: 1.4
11+
=======
12+
Stable tag: 1.3
13+
>>>>>>> origin/master
1014
1115
Requires at least: 3.0.1
1216

@@ -46,11 +50,15 @@ My other JSON API Auth plugin has also been integrated with this from version 1.
4650

4751
Hope this will help some.
4852

53+
<<<<<<< HEAD
4954
=Pro Version - JSON API User Plus=
5055

5156
A pro version of this plugin, JSON API User Plus, is available here http://www.parorrey.com/solutions/json-api-user-plus/ that supports BuddyPress Messages component, BuddyPress avatar upload and other BuddyPress related functions to integrate BuddyPress features in your mobile app via REST.
5257

5358
'JSON API User Plus' includes API key which protects and restricts the endpoint calls. This key can be updated from Settings > User Plus options page. Your app must include this key with every call to get the data from REST API. Please see documentation for calling endpoints examples for 'JSON API User Plus'.
59+
=======
60+
For details: http://www.parorrey.com/solutions/json-api-user/ A pro-version of this plugin will be available shortly that will support BuddyPress Messages component, BuddyPress avatar upload and other BuddyPress related functions to integrate BuddyPress features to your mobile app via REST.
61+
>>>>>>> origin/master
5462
5563
==Installation==
5664

@@ -177,12 +185,19 @@ http://localhost/api/user/delete_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE
177185

178186
= Method: update_user_meta =
179187

188+
<<<<<<< HEAD
180189
It needs 'cookie' and 'meta_key' var and 'meta_value' to update. You may send multiple values separated by comma.
181190

182191
http://localhost/api/user/update_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE&meta_value=VALUE-HERE
183192

184193
http://localhost/api/user/update_user_meta/?cookie=COOKIE-HERE&&meta_key=KEY-HERE&meta_value=value1,value2,value3
185194

195+
=======
196+
It needs 'cookie' and 'meta_key' var and 'meta_value' to update.
197+
198+
http://localhost/api/user/update_user_meta/?cookie=COOKIE-HERE&meta_key=KEY-HERE&meta_value=VALUE-HERE
199+
200+
>>>>>>> origin/master
186201
= Method: get_user_meta =
187202

188203
It needs 'user_id'. 'meta_key' var is optional.
@@ -231,4 +246,8 @@ It needs 'cookie', 'post_id', 'content', 'comment_status' vars.
231246

232247
http://localhost/api/user/post_comment/?cookie=COOKIE-HERE&post_id=ID&content=Comment contents here&comment_status=1
233248

234-
For additional features, pro version plugin details check here http://www.parorrey.com/solutions/json-api-user-plus/
249+
<<<<<<< HEAD
250+
For additional features, pro version plugin details check here http://www.parorrey.com/solutions/json-api-user-plus/
251+
=======
252+
For details, check here http://www.parorrey.com/solutions/json-api-user/
253+
>>>>>>> origin/master

0 commit comments

Comments
 (0)