Skip Navigation

[Resolved] Remove add button from relationship post

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2297225
Screenshot 2022-02-19 at 4.12.11 PM.png

Dear Sir/Madam,

Refer to the screenshot, is it possible to remove the Add button? I don't user can add post from here?

Best regards,

Kelvin.

#2298435

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no native way to remove "Add New" button but we can workaround it either by adding custom CSS or JS code.

I would like to know for what users you would like to remove the Add new button. With what user role you want to hide/remove the add new button?

#2309151

Dear Minesh,

I have custom Toolset user role say 'staff', only the administrator or staff can "Add New".

Best regards,

Kelvin.

#2310045

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add the following custom code to your theme's functions.php file or "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

function func_hild_add_new_post_relationship_box_button() {
    $user = wp_get_current_user();
  
    if ( !in_array( 'administrator', (array) $user->roles) or  !in_array( 'staff', (array) $user->roles) ) {

        echo '<style>  .types-related-content .types-related-content-actions input.button:nth-of-type(1){
        		display: none !important;
        } 
        </style>';
     
    }  
}
add_action( 'admin_head', 'func_hild_add_new_post_relationship_box_button' );