WP and Discourse not in sync using SSO

Excellent, I’ll start working on that… Thanks for your time

Edit

I thought I’d share this, it saved me a ton of time.

I managed to show one menu item containing the discourse SSO handler link to logged in users and another menu item containing the direct link for visitors by using the If Menu plugin.

It seems to work pretty well, I just needed to add a custom condition using the available filter.

here’s the new custom condition snippet

// Modify the If Menu plugin by adding conditions
add_filter( 'if_menu_conditions', 'spb_add_if_menu_conditions' );
function spb_add_if_menu_conditions( $conditions ) {
  $conditions[] = [
    'name'    =>  'User is not logged in',
    'condition' =>  function() {
      if( !is_user_logged_in() ) return true;
     },
    'group' => 'User state & roles',
  ];

  return $conditions;

}

Simple and neat!

1 Like