BuddyDev

Search

[Resolved] BP (un-)lock activity for admin only?

  • Participant
    Level: Master
    Posts: 279
    Richard Foley on #23405

    hi Brajesh,

    I’ve got your small but excellent plugin for locking activity entries working nicely, on my site.

    https://buddydev.com/plugins/bp-lock-unlock-activity/

    It feels like it’s lacking some configuration. Because the admin can always open/close an activity, even a simple “allow user to open/close?” would do it. Any chance of this being implemented…?

    R.

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #23410

    Hi Richard,
    Can you please help me understand it better.

    Do you want us to put a default status(open/close) by default?

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    Richard Foley on #23412

    nope. I would like to be able to say either:

    1. admin and user can both un/lock their own (admin=all) activity.

    This (1. above) is how the plugin behaves at the moment and is very good, I just don’t want the user to be able to unlock their activity after the admin has locked it. It is ok if the user can *lock* their activity. The simplest solution may be to not permit the user to unlock their activity, as per (2.) below.

    2. admin *only* can unlock/open activity. <- this is what I need.

    Does that make sense?

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #23445

    Hi Richard,

    Thank you for the clarification.

    I am requesting @ravisharma to test and put an update for you.

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #23449

    Hello Richard,

    Please download the latest version of plugin “BuddyPress Lock UnLock Activity” and use the following code which allows only site admins can lock and unlock an activity.

    
    /**
     * Only allow site admins to lock and unlock activity
     *
     * @param bool $can True or false.
     *
     * @return bool
     */
    function buddydev_user_can_lock_unlock_activity( $can ) {
    	return is_super_admin();
    }
    
    add_filter( 'bp_lock_unlock_user_can_update_activity', 'buddydev_user_can_lock_unlock_activity' );
    

    You can put this code in “bp-custom.php” or active theme “functions.php” file. Please let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 279
    Richard Foley on #23450

    hi Brajesh and Ravi,

    have installed as instructed and the code looks like it’s working perfectly, and exactly as needed.

    Many thanks for your support!

    R

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #23453

    Hello Richard,

    Thank you for the acknowledgement.

    Regards
    Ravi

The topic ‘ [Resolved] BP (un-)lock activity for admin only?’ is closed to new replies.

This topic is: resolved