Est*_*n S 5 php wordpress twitch
我正在使用Wordpress开发应用程序。我想在使用Twitch TV使用OAuth登录后检查用户是否是分配角色的频道的订户。我认为可以使用Twitch API与用户调用对象,然后检查该用户是否为具有另一个GET的脚本,但是如果我打印$ twitchuser且$ suscript为无效,则可以完成此操作。我是PHP新手,您知道错误在哪里,或者是否有其他解决方法?我的函数包含在wp-includes/user.php文件末尾:
function your_function() {
// Check if the user is Twitch suscriptor
if ( !is_super_admin() ) {
$twitchuser = $_GET["https://api.twitch.tv/kraken/user"];
$twitchname = $twitchuser['name'];
$suscript = $_GET["https://api.twitch.tv/kraken/channels/mychannel/subscriptions/{$twitchname}"];
if ($suscript == "404 Not Found") {
$current_user = wp_get_current_user();
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'nomember' );
}
}
}
add_action('wp_login', 'your_function');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
421 次 |
| 最近记录: |