• Resolved AliasgerSW

    (@aliasgersw)


    Is it possible to have approval mechanism only for certain user role or profile types(Buddy press)?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    As is, we just have our code run on user_register action hook, and haven’t changed things up yet that allows for conditional marking as pending, based on some sort of user role mechanism.

    I believe past support requests have had people add a hook on perhaps the 11 priority for the a callback on user_register and add in the user role checking there and if it matches, just mark the user as approved right away after.

    I don’t have any specific snippets of code for how to do that though, admittedly.

    Thread Starter AliasgerSW

    (@aliasgersw)

    Thanks @tw2113 for your reply.

    I got your point that we can approve that user after the execution of your function, but the matter is, in your function you’re sending an email to the admin for approval, which makes it confusing for the admin user because they will receive an email for the approval which is already been approved by the website.

    Can we have some sort of filter that we can implement in our child theme? We can inform you whether this user requires approval or not using that filter.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Good day,

    For some clarification, our plugin doesn’t disable access to the ENTIRE site, just the BuddyPress and generally bbPress areas of the website. If the user is only moderated, then they can still view the Buddy/bb areas in “read only mode” as best we can manage (we don’t have 100% 3rd party extensions protection for example). If set as a private network, they’re restricted to their profile in Buddy/bb.

    However, if you have a standard blog area, or contact pages, or an eCommerce shop, they’re able to interact with those areas with full access.

    A TLDR: we don’t prevent overall user activation, but we add a layer of approval for the Buddy/bb areas.

    For that last part, are you wanting a filter that would be able to be interacted with before the initial flagging as moderated in the context of our plugin? and perhaps return true/false on whether or not to mark them as such?

    Thread Starter AliasgerSW

    (@aliasgersw)

    Yes @tw2113 , if you provide filter for this, it may solve the request for me and for others.

    I got reply as well that you are not entirely disabling the user, you are just putting into moderated status to stop them performing any activity over the website

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I definitely get the idea, but at the same time, everything you need is technically already available to un-moderate a given user.

    We mark a new user as moderated on this add_action line:

    add_action( 'user_register', 
    'bp_registration_options_bp_core_register_account' );

    you could do something like

    function my_callback( $user_id ) {
        //check for user role with the $user_id
        ...
    
        // Set moderation status to not moderated
        bp_registration_set_moderation_status( $user_id, false );
    
    }
    add_action( 'user_register', 'my_callback', 11 );

    Do understand that I’m not fighting against the idea of filters as a whole, just noting that in a lot of ways it’s a little redundant in this specific spot.

    Thread Starter AliasgerSW

    (@aliasgersw)

    I got you @tw2113 , Thanks for your help.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Needs approval only for specific user role’ is closed to new replies.