Wp-discourse hook to hijack login

I have a client that’s using s2member and wants users who are not at a specific membership level to be redirected to an info page rather than being logged in to Discourse. (Don’t want to have them log in as a member of a cannot-read-a-thing group, they want them not to be logged in at all.)

Looks like the s2member stuff I need is here: Package s2Member\API_Functions ( Functions ) | s2Member Codex

I’m sure that there is a hook in wp-discourse that I can call that does this, but I don’t know where to look to figure out what it is.

Presumably I can find the s2member docs to check whether they are paying, but I’d accept hints on that too!

Found it.

add_action( 'wpdc_sso_provider_before_sso_redirect', 'wpdc_custom_check_user_membership', 10, 2 );
function wpdc_custom_check_user_membership( $user_id, $user ) {
    $s2member_access_level = get_user_field('s2member_access_level'); # An s2Member Membership Access Level number.
    if ( $s2member_access_level < 1 ) {
   wp_safe_redirect( 'https://myfishingcapecod.com/members-only-content/' );


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.