How To Disable Delete/Hide Listings Feature

Is there a PHP snippet that could help me disable both these options from the edit listing page -

  1. Delete Listings
  2. Hide Listing

As a temporary workaround, I’ve hidden these buttons using CSS. However, I’d prefer a PHP-based solution to fully disable these features. Any suggestions?

1 Like

Hi,

The most common option is to use a CSS snippet; other options will require a custom implementation. If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work Customize your website | HivePress

1 Like

Thanks for the clarification, Andrii :slight_smile:

I managed to write a PHP snippet. Is this okay?

add_filter(
    'hivepress/v1/templates/listing_edit_page',
    function( $template ) {
        return hivepress()->helper->merge_trees(
            $template,
            [
                'blocks' => [
                    'page_content' => [
                        'blocks' => [
                            'listing_delete_link'    => [
                                'type' => 'content',
                            ],
                            'listing_update_form'    => [
                                'blocks' => [
                                    'listing_delete_form' => [
                                        'type' => 'content',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'listing_actions_secondary' => [
                        'blocks' => [
                            'listing_delete_modal'    => [
                                'type' => 'content',
                            ],
                        ],
                    ],
                ],
            ]
        );
    },
    1000
);

Thanks :slight_smile:

1 Like

Hi,

Yes, this snippet seems to look correct, and it should hide the Delete button.

2 Likes

Great, thank you :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.