Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gaupoit
Last active June 14, 2020 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaupoit/02e47b5f241793a1f7928217b50d657a to your computer and use it in GitHub Desktop.
Save gaupoit/02e47b5f241793a1f7928217b50d657a to your computer and use it in GitHub Desktop.
Integrate PDA Gold with Simple WordPress Membership
<?php
add_filter( 'pda_before_handle_normal_fap', 'pda_handle_simple_membership', 10, 3 );
/**
* Callback to handle before checking FAP. This function will help to fix the problem
* when WordPress cookie expired before Simple WordPress Membership one.
*
* @param bool $is_valid_fap Flag to know whether FAP is valid.
* @param int $attachment_id The attachment ID.
* @param string $fap_type FAP type.
*
* @return bool
*/
function pda_handle_simple_membership( $is_valid_fap, $attachment_id, $fap_type ) {
if ( ! method_exists( 'SwpmMemberUtils', 'is_member_logged_in' ) ) {
return $is_valid_fap;
}
if ( SwpmMemberUtils::is_member_logged_in() ) {
return true;
}
return $is_valid_fap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment