使用 WP Discourse SSO 管理 Discourse 中的群组成员

在此留下一个与 https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724#restricting-access-to-discourse-when-a-membership-doesnt-exist-4 相关的笔记。如果启用了 WP Discourse 的“登录时创建或同步 Discourse 用户”选项,则所有 WordPress 站点的用户都将自动创建 Discourse 帐户,即使他们通过 OP 中概述的方法无法登录 Discourse。有关如何阻止为不具有适当会员级别的用户自动创建帐户的详细信息,请参阅此帖子的第二部分:How to prevent some WP users from being able to login to Discourse - #2 by simon

基本上:

add_filter( 'wpdc_bypass_sync_sso', 'wpdc_custom_bypass_sync_sso', 10, 3 );
function wpdc_custom_bypass_sync_sso( $bypass_sync, $user_id, $user ) {
    if ( /* Some condition that returns true if the user doesn't meet the membership requirement */  ) {

        $bypass_sync = true;
    }

    return $bypass_sync;
}

我在此给自己设置一个提醒,以便将这些详细信息更新到 OP 中。

2 个赞