Skip Navigation

[Resolved] Manage Toolset Button toolbar above editor

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to hide several Toolset buttons above the WYSIWYG editor panel in a CRED form, but I would like to continue to display the "Add Media" button.

Solution:
Modify this template to work for your needs:

function remove_toolset_buttons(){
 
    // $post not available with init hook
    $postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
    $target_pages = array( 123, 456, 789 ); // Comma-separated list of IDs of posts/pages where CRED forms are displayed
 
    if ( in_array( $postID, $target_pages ) ) {
 
        // remove the Fields and Views button
        add_filter( 'toolset_editor_add_form_buttons', function(){
          return current_user_can('administrator');
        } );
 
 
        // remove the CRED button
        add_filter( 'toolset_cred_button_before_print', function(){
          return current_user_can('administrator');
        } );
 
        // remove the Access button for certain roles
        add_filter( 'toolset_editor_add_access_button', function(){
            $roles = array( 'editor', 'contributor', 'author', 'subscriber' );
            return $roles;
        } );
    }
}
add_action( 'init', 'remove_toolset_buttons' );
This support ticket is created 6 years, 8 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 3 voices.

Last updated by lucaO 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#903951
sc5.png
sc4.png
sc3.png
sc2.png
sc1.png

I am trying to:

Hi,
I'm using Posts Table Pro (PTPro) for integrating custom posts fields created with Toolset.
One of the custom fields is a container for an uploaded file, which when fetched by PTPro shows the whole file URL. Id' like to have the title of the field to be displayed, as a clickable link, not the whole URL for the file.

I have added some code to functions.php as given in Toolset forum, in order to convert the URL to a clickable text string, and it works fine when I display that custom field in a single post . However I can't get the same in PTPro. Is there a way to solve that?

I attach here some screenshots so that you can have a close check. Thanks for your help.

Kind regards,

Luca

#904266

This code could be of interest to you:
https://toolset.com/forums/topic/print-out-file-name-in-view-template/#post-34741

However, in our GUI where we provide the methods to display those Fields, you can choose what to output:
- a raw URL
- a link with a title, class and style

This is how Toolset Fields should be displayed, as they are not supposed to be used to populate 3rd party data sets - this is because often our Fields are output with some HTML and not as raw values, and other plugins creating queries with this data may require the raw data.
It is possible for most fields to output the raw, saved value, but this does not include any label or title, logically.

To output a clickable link to the file, you can use:

[types field="file" title="Custom Title"][/types]
#905723

Hi Beda,

In order to bypass the related issue, since I disabled media buttons through the form (to avoid confusion with the many Toolset buttons for my customers), I tried to insert into the wysiwyg toolbar a button that will make editing easier for CRED forms (on frontend). I've achieved that through a plugin, "Wordpress TinyMCE custom upload". That upload button shows up in the backend, but not on CRED frontend. I've also added another plugin, "WP Edit Pro", that allows customisation of the wysiwyg bars. Customisations done with that plugin won't apply in CRED frontend forms either. This is quite frustrating, since there's no good and simple way for lambda users to upload a file in frontend unless the "hide media buttons" is unchecked (thus showing all the others buttons too). There are several threads about that issue, so I don't get why this hasn't been solved in Toolset so far as a specific option.
I tried to add code to functions.php and the css, but none of the solutions found in the forums did work. Thanks to help me find a solution again.

Best regards,

Luca

#905801

Can you show me a screenshot of the buttons in the CRED form, and tell me which ones you would like to show and which ones you would like to hide? I will try to find the best solution for you.

#906210
Capture_d’écran_2018-05-30_à_12_03_34.jpg
Capture_d’écran_2018-05-30_à_12_01_57.jpg
Ajouter_Articles_Références_Outils_–_Intranet_CREER.jpg

Hi, here are the screenshots.

Note that if some css has to be used, I'd prefer to use the custom css option in my theme (Soledad by Penci Design).

I use a plugin (PHP Inserter) to add code to functions.php.

Whether PHP or css, I prefer not to edit theme files.

Some of the buttons in the wysiwyg are not from Toolset. What I need to achieve mostly, is have the wysiwyg bar in CRED forms to show the upload button (from upload plugin) or on top of it, the Add Media button.

Thanks for your help.

#906351

Okay I can't offer much advice for the non-Toolset buttons, but I think I can help with the others. First, turn on the Add Media button in the CRED form editor screen. Then use the following code template to manage button display:

function remove_toolset_buttons(){

    // $post not available with init hook
    $postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
    $target_pages = array( 123, 456, 789 ); // Comma-separated list of IDs of posts/pages where CRED forms are displayed

    if ( in_array( $postID, $target_pages ) ) {

        // remove the Fields and Views button
        add_filter( 'toolset_editor_add_form_buttons', function(){
          return current_user_can('administrator');
        } );


        // remove the CRED button
        add_filter( 'toolset_cred_button_before_print', function(){
          return current_user_can('administrator');
        } );

        // remove the Access button for certain roles
        add_filter( 'toolset_editor_add_access_button', function(){
            $roles = array( 'editor', 'contributor', 'author', 'subscriber' );
            return $roles;
        } );
    }
}
add_action( 'init', 'remove_toolset_buttons' );

Change 123, 456, 789 to be a comma-separated list of the IDs of posts or pages where CRED forms are displayed. Then you can modify the $roles array to hide the Access button from certain roles. If you add roles to the list here, the Access button will be hidden from those Users.

#906423

That code worked like a charm, thank you so much.
The other non-Toolset plugins have an option to hide the button from the wysiwyg editor.