Hi,
I am using the BuddyBlog Plugin and I would like to hide the tab “New Post” in order that the members cannot write new post this way, as I am using another plugin to write posts.
Has someone a solution to hide this “New Post” Tab ?
Thank you.
Kind regards,
DanielHello Daniel,
Please try the following code in your “bp-custom.php” and let me know if it works or not.
function buddydev_remove_new_post_tab() { bp_core_remove_subnav_item( buddypress()->buddyblog->slug, 'edit' ); } add_action( 'bp_buddyblog_setup_nav', 'buddydev_remove_new_post_tab' ); function buddydev_remove_admin_new_post_tab( $wp_admin_nav_items ) { $new_admin_items = array(); foreach ( $wp_admin_nav_items as $wp_admin_nav_item ) { if ( $wp_admin_nav_item['id'] == 'my-account-' . buddypress()->buddyblog->id . '-new-post' ) { continue; } $new_admin_items[] = $wp_admin_nav_item; } return $new_admin_items; } add_filter( 'bp_buddyblog_admin_nav', 'buddydev_remove_admin_new_post_tab' );
For “bp-custom.php” you can refer followin url:
https://codex.buddypress.org/themes/bp-custom-php/Thank You
RaviHi Ravi,
Thanks for your reply.
I have created the bp-custom.php file as per the link you have provided and I have copy your code inside the file and added the file under wp-content/plugins.
Unfortunately, the code you have provided did not work. I still can see the “New Post” Tab.
Kind regards,
DanielHello Daniel,
Just paste me the whole file code of the file “bp-custom.php” so that I can check. You can post the code into pastebin.
Thank you
RaviHi Ravi,
Basically, I had no bp-custom.php file, so what I did was I have created an empty bp-custom.php file and I have copied your code you have provided into the empty bp-custom.php file.
Therefore, the whole file code of my bp-custom.php file is the same as the code you have provided above. Means, there is no other code included other than your code.
I hope this helps.
If you want you can send me an email and I will attach the bp-custom.php file and send you back an email.
Thank you and please let me know if I can provide any further information.
Kind regards,
DanielHello Daniel,
Thank you for the clarification seems you have not included “<?php” tag. Just remove the old code and paste the following code into that file
<?php function buddydev_remove_new_post_tab() { bp_core_remove_subnav_item( buddypress()->buddyblog->slug, 'edit' ); } add_action( 'bp_buddyblog_setup_nav', 'buddydev_remove_new_post_tab' ); function buddydev_remove_admin_new_post_tab( $wp_admin_nav_items ) { $new_admin_items = array(); foreach ( $wp_admin_nav_items as $wp_admin_nav_item ) { if ( $wp_admin_nav_item['id'] == 'my-account-' . buddypress()->buddyblog->id . '-new-post' ) { continue; } $new_admin_items[] = $wp_admin_nav_item; } return $new_admin_items; } add_filter( 'bp_buddyblog_admin_nav', 'buddydev_remove_admin_new_post_tab' );
and let me know if it works or not
Thank You
RaviHi Ravi,
I have tested the code and the tab “New Post” has disappeared with success.
But the problem now is, that the user cannot EDIT his post anymore after I have inserted your code.
When the user wants to EDIT his post, then the user gets redirected to the search page and it says:
“It looks like nothing was found at this location. (And then it shows the Search bar underneath.)
I only want that the “New Post” Tab disappears and not more. But I still would like that the user can EDIT his post.
Is there a way to only hide the “New Post” Tab but that the user still can EDIT his post ?
Thank you for your support.
Kind regards,
DanielHello Daniel,
Replace the previous code with the following code. It will only show tab on edit post screen.
function buddydev_remove_new_post_tab() { if( ! buddyblog_is_edit_post() ) { bp_core_remove_subnav_item( buddypress()->buddyblog->slug, 'edit' ); } } add_action( 'bp_buddyblog_setup_nav', 'buddydev_remove_new_post_tab' ); function buddydev_remove_admin_new_post_tab( $wp_admin_nav_items ) { if ( ! buddyblog_is_edit_post() ) { $new_admin_items = array(); foreach ( $wp_admin_nav_items as $wp_admin_nav_item ) { if ( $wp_admin_nav_item['id'] == 'my-account-' . buddypress()->buddyblog->id . '-new-post' ) { continue; } $new_admin_items[] = $wp_admin_nav_item; } return $new_admin_items; } return $wp_admin_nav_items; } add_filter( 'bp_buddyblog_admin_nav', 'buddydev_remove_admin_new_post_tab' );
And let me know if it works or not.
Regards
Ravi
The topic ‘ [Resolved] Hide the Tab "New Post" in BuddyBlog Plugin’ is closed to new replies.