Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

  • @5high

    Participant

    Thought I’d post this here in case others are looking for the same solution – and in case I’ve done it incorrectly of course!

    What I wanted was to hide the “whats-new-form” in a member’s activity area, so that they can’t post from here, YET to keep it available for everyone in the Groups. The reason is i want to keep all comments within Groups only.

    So I put this code into my child theme css;

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

    It seems to have done the trick, once the ‘role’ bit was added in.

    If this is the wrong way to disable members to post in their personal activity I’d appreciate some input, as I’m new to BuddyPress.

    Cheers.

Viewing 22 replies - 1 through 22 (of 22 total)
  • @hnla

    Participant

    You only need a member with the most basic knowledge of css to be workaround that; CSS is not the correct way to ‘remove’ something.

    You should really overload/copy the activity index.php file to your theme or child theme and edit the include line that calls the post-form.php file, and remove it now the main activity directory won’t have the whats new form, same with the members profile in /members/single/activity.php find the include line for the post form and remove.

    Check the codex theme section for guides on working with BP template files and how to correctly overload them to your theme to be able to edit them safely.

    @5high

    Participant

    Thanks for your reply @hnla.

    I’ve read through some of the codex and form what I understand I need to make a buddypress folder in my child theme and then add the files I want to edit into this so it loads first – all good there. OR that I cam edit BP actions by putting edits in a newly created bp-custom.php – which I’ve done and added into the root folder for the main plugins (/wp-content/plugins) ready for any customizations.

    I’ve searched extensively in the BP files on my server including:
    /wp-content/plugins/buddypress/bp-members/bp-members-activity.php
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress-functions.php
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/index.php
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/activity.php
    … but can’t find the “whats-new-form” referenced there.

    I’ve found some info re. “whats-new-form” in a couple of files:
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/post-form.php
    /wp-content/plugins/buddypress/bp-themes/bp-default/activity/post-form.php
    …both of which seem to relate to the role=”complementary”, so not related to the member activity only section that I’m after (role=main).

    And the activity index file you mentioned:
    /wp-content/plugins/buddypress/bp-themes/bp-default/members/single/activity.php
    …did contain role=main but not the “whats-new-form”.

    My grasp of php is limited and I can’t for the life of me work out what to do with all this!

    Your suggestions would be appreciated – or links to info for this instead.

    many thanks.

    @5high

    Participant

    OK, as no other info I’ve stuck to original idea of removing it with css and it’s worked really well!
    Sorted!

    @danbp

    Participant

    hi @5high,

    as @hnla mentionned it, CSS is not the correct way to ‘remove’ something, because it’s not removed from source code, but only hidden to visitors.

    Here is a solution to remove what’s new form from the activity page, but let it live for groups.

    1) copy bp-templates/bp-legacy/buddypress/activity/index.php
    to the child-theme, to get /child-theme/buddypress/activity/index.php

    2) open the copied file and remove line 7 to 11

    
    <?php if ( is_user_logged_in() ) : ?>
    
       <?php bp_get_template_part( 'activity/post-form' ); ?>
    
    <?php endif; ?>

    To remove the form from members single activities

    3) copy bp-templates/bp-legacy/buddypress/members/single/activity.php,
    to the child-theme, to get /child-theme/buddypress/members/single/activity.php

    4) remove only line 35

    bp_get_template_part( 'activity/post-form' );

    Hope this help.

    @5high

    Participant

    Wow – that’s excellent info! Thanks so much for that. I am gradually learning how BP is put together, so I’m sure it’ll get easier!
    Cheers 🙂

    @danbp

    Participant

    You’re welcome. 😉

    FYI, reading the codex and this forum is a good way to learn.

    And if you like BP, don’t forget the 2015 Survey. 😉

    @5high

    Participant

    OK, I’m becoming a bit more familiar with BP, so now want to tackle your recommended code above. Just a quick question for you @danbp first: when you said…

    Here is a solution to remove what’s new form from the activity page, but let it live for groups.

    Can you confirm that means that all users can still post comments in all group threads, but removes that option in their profile section? ie. forcing all comments/activity to be via the Groups? – as per my original aim?

    And if so, why do I have to do both edits to achieve this?

    Sorry to be a pain, but we’re about to go live and I don’t want to mess it up now!

    Cheers.

    @hnla

    Participant

    > Can you confirm that means that all users can still post comments in all group threads,

    And how did your tests turn out? Really it’s a question best answered by testing the outcome on a development or staging server, but yes this process will leave only groups activity posting working.

    You need to edit the files where the whats new post form is called so yes two files for the main activity directory page and the members activity index, then your single groups activity stays as is.

    @5high

    Participant

    Back again, after just completing the above edits and BINGO! it works! But only because i followed your very clear step-by-step instructions above. Thank you @danbp and @hnla for your help and support – Only possible by the ‘paint by numbers’ approach for me at present!

    I presume that if i want to ‘hide a couple of other things in a user’s profile section I could do it the same way (just don’t know where of course!)? Both are in a user’s profile > Settings; one is the ‘Profile Visibilty’ tab and the other is the bottom section of the ‘Email’ notifications tab, which shows the Groups email notifications options (as I’ve set them all to default as off for new users, via my functions.php).

    But I’m happy to start a new thread for this as it might be better for others to follow?

    Cheers.

    @froster2

    Participant

    Hey guys,

    How can I hide the “whats-new-form” when viewing another member’s wall, but keep it displayed for the logged in user’s personal wall?

    Thank you

    @danbp

    Participant

    @froster2,

    add a conditionnal to existing on template for that element.
    $user_id != bp_loggedin_user_id()

    In /child-theme/buddypress/members/single/activity.php
    Replace line 48 or so with this:

    if ( is_user_logged_in() && bp_is_my_profile() && ( $user_id != bp_loggedin_user_id() ) && ( !bp_current_action() || bp_is_current_action( 'just-me' ) ) )

    @5high

    Participant

    Hi again – @danbp, this code doesn’t seem to be working anymore, so the ‘What’s New?’ box is now showing again. I’ve downloaded new copies of the files you said to edit and removed the same lines of code but no change.
    Can you confirm which lines of code to remove please? ….to remove what’s new form from the activity page, but let it live for groups.
    Many thanks.

    @5high

    Participant

    ps: it appears that all of the What’s New forms now have a different role: [role=complimentary] where before it was role=main.
    So not sure if it is now even possible to remove the What’s New? form from the site-wide activity stream and the member’s activity stream yet KEEP it in the GROUPS activity?

    If I can’t do this, then is there a way to remove the profile option in the ‘what’s new post in’ box, in the site-wide activity?

    Many thanks.

    @danbp

    Participant

    @5high Yep! You’re right. The form is now build separately. To hide it conditionnaly, it’s much easier as previously.

    What you have to do from now on, is to add a condition on the template part call.

    The form template file is post-form.php (activity/post-form.php)

    On each activity template (swa, members, groups,…), there a call to this file. bp_get_template_part( 'activity/post-form' );

    To solve your problem, you have just to add the condition you want for this call.

    In your case, as you want to disallow the form only on swa and on member’s activity, you modify
    child-theme/buddypress/activity/index.php (site wide activity) and child-theme/buddypress/members/single/activity.php (profile activity)

    For example i hide the form to any user except site admin by using:

    if ( is_user_logged_in() && is_super_admin() )
    	bp_get_template_part( 'activity/post-form' );

    Hope to be clear ! 😉

    @5high

    Participant

    @danbp – really appreciate you getting back to me on this!

    So is it correct to remove/comment out the whole of this call for this template as i don’t want it for anyone on the swa or the profile activity? Like this…

    – ie.remove all of this for the swa index.php:

    	do_action( 'bp_before_directory_activity_content' ); ?>
    
    	<?php if ( is_user_logged_in() ) : ?>
    
    		<?php bp_get_template_part( 'activity/post-form' ); ?>
    
    	<?php endif; ?>
    
    	<?php

    – and remove all of this in the member profile activity.php:

    do_action( 'bp_before_member_activity_post_form' ); ?>
    
    <?php
    if ( is_user_logged_in() && bp_is_my_profile() && ( !bp_current_action() || bp_is_current_action( 'just-me' ) ) )
    	bp_get_template_part( 'activity/post-form' );
    
    /**
     * Fires after the display of the member activity post form.
     *
     * @since 1.2.0
     */
    do_action( 'bp_after_member_activity_post_form' );

    Many thanks.

    @5high

    Participant

    OK, I’m a php newbie and so am guessing here and have tried 3 ways to remove the form from the swa:
    1. commenting out all of the ‘do action’ code as above = no change, form still shows
    2. removed the ‘activity/post-form’ from the code and left the rest as is = no change, form still shows!
    3. removed all the conditional php bit within the <?php if ….. to … <?php endif; ?> = still no change and the form is still there but the rest of the site activity wasn’t!

    So I’m afraid I’ll need an idiots explanation of how to remove it in each of these forms. If you have the time (and patience) for this that’d be great 🙂

    @danbp

    Participant

    It’s a possibility !
    Personally i wouldn’t remove the action hooks, so they can be used by other plugins or even BP. Who knows ?

    @danbp

    Participant

    My answer was later as your’s.

    – do you use a child-theme ?
    – do you use some cache plugin ?

    I haven’t time to teach you php. But a little tip when you do such things.

    Before to remove code (php or html), try to ADD something to the original code. ie. a simple word who then appear on the template. This can give you an idea from where to start.

    @5high

    Participant

    @danbp – Just had another chance of reviewing this and finally the penny’s dropped! So I now totally understand what you’re doing and where the code goes and it works as expected! (as I’m sure you knew it would…)
    Though one of the issues before, rather embarrassingly, was that after migrating my site and retesting with the original theme I’d then forgotten to change it back to my child theme – so all my edits weren’t taking effect – duh!
    So now it works AND it has the correct code in.
    many thanks for your time again, j

    @5high

    Participant

    uh oh – just logged a php error for the new code. The error reported was this:

    PHP Parse error: syntax error, unexpected ‘endif’ (T_ENDIF) in /home/mysite/public_html/wp-content/themes/child-theme/buddypress/activity/index.php on line 34

    But when I look at this file I’m pretty sure it’s the same as what you posted =

    <?php if ( is_user_logged_in() && is_super_admin() ) ?>
    	 
    	   <?php bp_get_template_part( 'activity/post-form' ); ?>
    
    	<?php endif; ?>

    and line 34 is: <?php endif; ?> which I’m pretty sure I didn’t change!

    Can anyone spot what the problem is here?

    Many thanks, j

    @danbp

    Participant

    There is a typo error in your code. The if is missing a:

    <?php if ( is_user_logged_in() && is_super_admin() ) ?>

    should be

    <?php if ( is_user_logged_in() && is_super_admin() ) : ?>

    @5high

    Participant

    @danbp – well spotted! Thanks, no more php errors showing and it’s working perfectly.

    Cheers, j

Viewing 22 replies - 1 through 22 (of 22 total)
  • The topic ‘[Resolved] hiding “whats-new-form” in member activity but NOT in Groups’ is closed to new replies.
Skip to toolbar