File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,28 @@ function json_oauth_load() {
59
59
add_filter ( 'determine_current_user ' , array ( $ wp_json_authentication_oauth1 , 'authenticate ' ) );
60
60
add_filter ( 'json_authentication_errors ' , array ( $ wp_json_authentication_oauth1 , 'get_authentication_errors ' ) );
61
61
}
62
- add_action ( 'plugins_loaded ' , 'json_oauth_load ' );
62
+ add_action ( 'init ' , 'json_oauth_load ' );
63
+
64
+ /**
65
+ * Force reauthentication after we've registered our handler
66
+ *
67
+ * We could have checked authentication before OAuth was loaded. If so, let's
68
+ * try and reauthenticate now that OAuth is loaded.
69
+ */
70
+ function json_oauth_force_reauthentication () {
71
+ if ( is_user_logged_in () ) {
72
+ // Another handler has already worked successfully, no need to
73
+ // reauthenticate.
74
+
75
+ return ;
76
+ }
77
+
78
+ // Force reauthentication
79
+ global $ current_user ;
80
+ $ current_user = null ;
81
+ get_currentuserinfo ();
82
+ }
83
+ add_action ( 'init ' , 'json_oauth_force_reauthentication ' , 100 );
63
84
64
85
/**
65
86
* Load the JSON API
You can’t perform that action at this time.
0 commit comments