BuddyDev

Search

[Resolved] Hiding “whats-new-form” in member activity but NOT in Groups

  • Participant
    Level: Enlightened
    Posts: 39
    yuriix on #44192

    Hello,

    can you advise me how to disable the “whats-new-form” in activities but not in groups? In groups it should still be visible so users can post.

    I found this

    div#item-body[role=main] form#whats-new-form {
    display: none;
    }

    here https://buddypress.org/support/topic/solution-for-hiding-whats-new-form-in-member-activity-but-not-in-groups/ but unfortunately it doesn’t work.

    Thank you

    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #44206

    Hi,
    Thank you for the question. The css may depend on your theme and template pack.

    Can you please tell me which theme and template pack are you using?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 39
  • Participant
    Level: Enlightened
    Posts: 39
    yuriix on #44215

    Screen of html and css https://imgur.com/a/17NPiME

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #44222

    Hi,
    Please consult your theme author. It will be a simple css but specific to your theme probably(the selector being used).

    I wasn’t able to login to their demo, otherwise I could have supplied the css.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 39
    yuriix on #44528

    Hello,
    I managed to hide the form for adding Activities (.my-account #whats-new-form{display:none !important}), but I still have one more question.

    Is it possible to somehow write to the Activity other than through the form? I would like to be the only one to add content there.

    Thank you.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #44529

    Hello Yuriix,

    Thank you for the acknowledgement. I am glad that you have resolved the issue on your own.

    Regarding your second requirement, Are you looking for a code that will restrict activity posting to only a certain user i.e. No other user can post activity?. If yes, please let me know what sort of activity you want to restrict the activity meaning User activity or group activity.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 39
    yuriix on #44530

    Hello,
    Yes, User activity.

    Thank you

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #44532

    Hello Yuriix,

    Please try the following code in the ‘bp-custom.php’ file.

    
    
    /**
     * Filter ajax post request
     */
    function buddydev_restrict_post_update() {
    	// Always allow site admin.
    	if ( is_super_admin() ) {
    		return;
    	}
    
    	$object = empty( $_POST['object'] ) ? '' : sanitize_key( $_POST['object'] );
    
    	// Allowed user ids.
    	$allowed_user_ids = array( 10 );
    
    	if ( 'user' == $object && ! in_array( get_current_user_id(), $allowed_user_ids ) ) {
    		wp_send_json_error( array( 'message' => __( 'You are not allowed to post activity.' ) ) );
    	}
    }
    
    add_action( 'wp_ajax_post_update', 'buddydev_restrict_post_update', 9 );
    
    

    I am assuming you are using the BP Nouveau template pack.

  • Participant
    Level: Enlightened
    Posts: 39
    yuriix on #44577

    Hello,

    Unfortunately the script doesn’t work, even a user other than Admin can post.

    How do I find out which pack is used in the template?

The topic ‘ [Resolved] Hiding “whats-new-form” in member activity but NOT in Groups’ is closed to new replies.

This topic is: resolved