Help with changes

Accueil Forums Main plugin support Help with changes

20 sujets de 1 à 20 (sur un total de 41)
  • Auteur
    Messages
  • #477926
    Fabio
    Participant

    Hi I purchased the “front office publishing” module, in principle I am satisfied with the form; but I would like to make some changes and would like suggestions.
    1) On the dashboard page I would like to change the query; I would like to see the last files of the author, and not of the owner.
    2) On the “my files” page, I would automatically like the author’s files to appear, without having to click on the author’s link on the right (created by).
    3) In the file view page, along with the edit and delete button, I would like to insert a file download button.

    Can you kindly help me?
    Thank you so much

    #478038
    Thomas Lartaud
    Admin bbPress

    Hi,

    1 & 2) Queries can be edited by following those instructions.
    Also, we are actually finalizing a long update on the ACF integration add-on, and then we’ll work on a new way to display author and assigned pages more efficiently.

    3) Not sure that this is a great idea, because there can be multiple files with he enhanced files add-on (or you’ll need to also add a bit of javascript to support multiple files downloads).
    But, if you need it, a great starting point you could try this piece of code (add it in a standard WP plugin that you’ll need to create, and preferably add an underscore at the start of the plugin to make sure it’s loaded before WPCA plugins).
    I didn’t try but it should work. The problem of this code is that it will show multiple buttons for multiple files uploaded and you should adapt it in the case you use the enhanced files add-on.

    function custom_cuar_get_single_content_action_links($links)
    {
        if (is_admin()) return $links;
    
        $post_id = get_queried_object_id();
    
        $files = cuar_get_the_attached_files($post_id);
        if (isset($files) && !empty($files)) {
            foreach ($files as $file) {
                $links[] = array(
                    'title' => '<span class="fa fa-download"></span> ' . __('Download', 'cuar'),
                    'tooltip' => __('Download file(s)', 'cuar'),
                    'url' => $file['caption'],
                    'extra_class' => ''
                );
            }
        }
    
        return $links;
    }
    
    add_action('cuar/private-content/view/single-post-action-links?post-type=customer-private-file',
        'custom_cuar_get_single_content_action_links');
    
    add_action('cuar/private-container/view/single-post-action-links?post-type=customer-private-file',
        'custom_cuar_get_single_content_action_links');
    

    Regards.

    #478119
    Fabio
    Participant

    Excuse the insistence, but something is wrong …
    For points 1 and 2 the guide shown explains how to change the order and not the choice to display by author or owner in the dashboard or on the “my files” page. Also if I try the reported function it all crashes and I get a blank page.
    For point 3, I created the plugin, creating a .php file with the function you reported to me, activating the plugin, but I don’t see the download buttons (I don’t use the advanced module so it should work)
    I created the _myplug folder with the file myplug.php with the function inside

    #478143
    Thomas Lartaud
    Admin bbPress

    1 & 2) Our docs example are just some examples about manipulating standard WP_Queries.
    You could use var_dump($new_args); right before return $new_args;to see arguments passed to the query, and override some of them.

    3) Sorry, Just a typo, try this one :

    function custom_cuar_get_single_content_action_links($links)
    {
        if (is_admin()) return $links;
    
        $post_id = get_queried_object_id();
    
        $files = cuar_get_the_attached_files($post_id);
        if (isset($files) && !empty($files)) {
            foreach ($files as $file) {
                $links[] = array(
                    'title' => '<span class="fa fa-download"></span> ' . __('Download', 'cuar'),
                    'tooltip' => __('Download file(s)', 'cuar'),
                    'url' => $file['caption'],
                    'extra_class' => 'btn-primary'
                );
            }
        }
    
        return $links;
    }
    add_action('cuar/private-content/view/single-post-action-links?post-type=cuar_private_file',
        'custom_cuar_get_single_content_action_links', 50);
    add_action('cuar/private-container/view/single-post-action-links?post-type=cuar_private_file',
        'custom_cuar_get_single_content_action_links', 50);

    Regards.

    #478634
    Fabio
    Participant

    1 & 2) The problem is that if I try the simple function (in function.php) to see if it works, the site disappears.

    function cuar_custom_sorting_order( $args ) {
    $new_args = $args;
    $new_args[‘orderby’] = ‘modified’;
    $new_args[‘order’] = ‘DESC’;
    return $new_args;
    }

    $page_slug = ‘customer-private-files’;
    add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug, ‘cuar_custom_sorting_order’ );

    Then where should I try?
    var_dump ($ new_args);
    return $ new_args;

    But can’t you tell me the page where I have to go directly to edit the queries, since the function doesn’t work?

    for point 3: the button appeared, but it links incorrectly, causing nothing to be downloaded.

    #479081
    Thomas Lartaud
    Admin bbPress

    Hi,

    Use this code preferably in a plugin because plugins are executed earlier. Some functions might not work if executed in the functions.php file.

    function cuar_custom_sorting_order( $args ) {
    $new_args = $args;
    $new_args['orderby'] = 'modified';
    $new_args['order'] = 'DESC';
    
    var_dump($new_args);
    return $new_args;
    }
    
    $page_slug = 'customer-private-files';
    add_filter( 'cuar/core/page/query-args?slug=' . $page_slug, 'cuar_custom_sorting_order' );
    

    This code, inside a WP plugin, should allow you to read the complete WP_Query, and change the arguments you need for your customizations.

    For more information about manipulating WP_Queries, see WP Codex.

    But can’t you tell me the page where I have to go directly to edit the queries, since the function doesn’t work?

    Which page about what? Don’t imagine a plugin would create a page to allow you to change the queries. This would be a headache to do and absolutely useless. You have to do it by code, no other way to do that, sorry.

    If you can’t do it by yourself, you’ll need to hire a WordPress developer from your country that can do this for you.

    the button appeared, but it links incorrectly, causing nothing to be downloaded.

    Not sure I understand but feel free to debug and/or adapt this function to suit your needs. As I said, I didn’t try this function, I just posted it to show you a way to access what you wanted, but I won’t debug this function until it works 100% as you need. It’s outside of our support scope to do such free customizations for each one of our clients.

    However, we are still here if you need information about the plugin itself, but we can’t help you learn PHP and or WP development, sorry.

    Regards.

    #479090
    Fabio
    Participant

    I set the plugin with the function indicated and I get this:
    array (6) {[“post_type”] => string (17) “cuar_private_file” [“posts_per_page”] => int (10) [“paged”] => int (1) [“orderby”] => string ( 8) “modified” [“order”] => string (4) “DESC” [“meta_query”] => array (2) {[“relation”] => string (2) “OR” [0] => array (3) {[“key”] => string (20) “cuar_owner_queryable” [“value”] => string (7) “| usr_3 |” [“appears”] => string (4) “LIKE”}}}
    Excuse my ignorance but I was expecting something that would allow me to modify the query “select * from table where autor = myautor”
    however if you list the changes I need you can get a quote. In the case it will be accepted I provide you with the access parameters.

    #479167
    Fabio
    Participant

    I analyzed the problem a lot by looking for a single and shorter way to solve the main problem (1 and 2)
    It is possible to make, when the file is created, the creator equal to the author is automatically set.
    Do not set a creator by default (as shown by the guide)
    So I would be solved.
    While for point 3, without your additional code, where do you download the file?

    #479175
    Thomas Lartaud
    Admin bbPress

    Sorry,

    I had thought you were feeling comfortable with PHP development. Finally, I think you are missing the minimal PHP knowledge required to do such customization. No offense here, but manipulating WP queries require some advanced knowledges in development. Please contact a WordPress developer in your area so that you can get a quote from him/her.

    Excuse my ignorance but I was expecting something that would allow me to modify the query “select * from table where autor = myautor”

    WP plugins do not use such queries, because WordPress has standard functions built for that, and we have to use them to follow WP standards and requirements.

    So, there’s nothing special here. I’m just deleting the WP meta_query arg and add a post_author one.
    However, I do not recommend using this piece of code because your users will not be able to see posts assigned to them anymore, and doing this is not tested. This means this could lead into unattended effects.

    function cuar_custom_sorting_order( $args ) {
    
        $new_args = $args;
        $new_args['orderby'] = 'modified';
        $new_args['order'] = 'DESC';
    
        unset($new_args['meta_query']);
        $new_args['post_author'] = get_current_user_id();
    
        return $new_args;
    }
    
    $page_slug = 'customer-private-files';
    add_filter( 'cuar/core/page/query-args?slug=' . $page_slug, 'cuar_custom_sorting_order' );
    

    Note: this is just a starting example to show you the way to go. You’ll probably need more manipulations into this function to get what you need.

    Hope that helps,

    Regards.

    #479210
    Thomas Lartaud
    Admin bbPress

    Also,

    Performing queries including meta_queries and fields like post_author is a bit complex with WordPress, but you’ll find many discussions about that on Stackoverflow.

    https://stackoverflow.com/questions/30916071/use-or-relation-for-meta-query-in-wordpress
    https://wordpress.stackexchange.com/questions/69355/author-page-custom-query-where-author-or-post-meta-value-or-post-meta-value

    Hope that helps,

    Regards.

    #479310
    Fabio
    Participant

    hi, after more than 6 hours between tests, manuals, and your blog I managed to solve a problem … I didn’t want to disturb you on points 1 and 2, it was also a question of dignity!
    Inside the file cuar_function.php there is the function cuar_custom_sorting_order intervening as suggested and using var_dump I understood a few things … but your code didn’t work with
    $ new_args [‘post_author’] = get_current_user_id ();
    but everything works with
    $ new_args [‘author’] = get_current_user_id ();

    Thank you for making me think.

    Only point 3 remains.
    I uninstalled the plug-in with the function you had told me to understand where the file is downloaded without finding it anywhere. Where does the download take place?

    A curiosity is it possible to limit the upload to just the pdf files?

    #479651
    Thomas Lartaud
    Admin bbPress

    Hi,

    Glad you fixed it.

    Files are downloaded in wp-content/customer-area/storage
    Images from the frontend editor are uploaded in wp-content/uploads/customer-area.

    A curiosity is it possible to limit the upload to just the pdf files?

    No, you’ll need to do this more generally on WordPress, on even on your server. See there.

    Regards.

    #479679
    Fabio
    Participant

    First of all thanks for the advice on upload limit to pdf files
    Surely there was a misunderstanding due to my beginner English.
    I didn’t ask where the files go following the upload.
    I was wondering where is the button to download the file from the user?
    By installing the reported code, the download button appears, but it doesn’t work …

    #479683
    Thomas Lartaud
    Admin bbPress

    I was wondering where is the button to download the file from the user?

    Same place as for the admin?

    Annotation-2019-05-21-140841

    If a user can not see it, you probably missed to set the capabilities in settings -> WP Customer Area -> capabilities?

    #479686
    Fabio
    Participant
    Cette réponse a été marquée comme privée.
    #479691
    Fabio
    Participant

    I don’t see that button you show in the picture

    #479692
    Thomas Lartaud
    Admin bbPress

    Make sure you added the function in a WP Plugin.

    #479694
    Thomas Lartaud
    Admin bbPress

    Can the user download the file using the standard download button ?

    #479702
    Fabio
    Participant

    there is no standard download button!

    #479708
    Thomas Lartaud
    Admin bbPress

    Wait, no button ? Don’t you see this ?

    Annotation-2019-05-21-145829

    Regards.

    Pièces jointes:
20 sujets de 1 à 20 (sur un total de 41)
  • Vous devez être connecté pour répondre à ce sujet.