• Hi,
    I used paidmemberPro
    I asked them:
    1/ This would allow or not, the ability to follow a person
    2/ possibly display (or not) in profile)

    They said:
    It depends on the filters & hooks supported by the buddypress followers plugin…

    If they have a filter that can be used to prevent a user from following another one could use the pmpro_getMembershipLevelForUser(), or a similar function to check whether the $current_user has the right membership level for that feature/capability to be allowed.

    Is it possible ??

    https://www.ads-software.com/plugins/buddypress-followers/

    [ No bumping please. ]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author r-a-y

    (@r-a-y)

    If you hook into 'bp_follow_before_save' action and wipe out the $leader_id, you should be able to bail out of saving a follow relationship.

    View the codebase for more info:
    https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-classes.php#L86-L93

    Thread Starter HDcms

    (@hdcms)

    Hi,

    If user B (who in this case doesn’t have the required membership level to follow someone) is attempting to follow another user (user A), i want user B to be redirected to the PMPRo Levels page

    add_action( 'bp_follow_before_save', 'my_pmpbb_deny_follow', 10 );
    function my_pmpbb_deny_follow( $follow ){
      if ((pmpro_hasMembershipLevel(array('0','1','2')))==true) {
         $follow->leader_id = null;
         wp_redirect(pmpro_url("levels"));
           exit();
      }
    }

    My code does not work because it displays the “PMPRo Levels page” on the same page (ajax?)

    How to do ?
    Regards

    Plugin Author r-a-y

    (@r-a-y)

    You cannot issue a redirect from an AJAX button request.

    Another way around this is to remove the follow button if your user should not have access to that button.

    Use the 'bp_follow_get_add_follow_button' filter to determine if user B (the follower ID) can follow user A (the leader ID):
    https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-templatetags.php#L217

    If user B cannot follow, wipe out the button arguments so the button is not rendered.

    Thread Starter HDcms

    (@hdcms)

    Hello
    Thank you for your reply
    I’ll watch it, even if it seems a little complicated for me. I preferred redirect to the membership page for a better user experience !
    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘paid-memberships-pro and BuddyPress Follow’ is closed to new replies.