• Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
  • Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
home/Knowledge Base/Code snippets/Allow contents listings to also show private contents that are authored by the current connected user

Allow contents listings to also show private contents that are authored by the current connected user

291 views 0 April 13, 2021

Since 7.7.0

By default, WP Customer Area is only displaying contents assigned to the current user on listing pages. There is a feature that allows you to also display contents created by the current user, but it is disabled by default.

This code snippet will allow you to also display contents authored by the currently connected user.

/**
 * Re-enable display of contents authored by the currently connect user on listing pages
 *
 * @param bool $disabled The actual state of the feature
 * @return bool $disabled The new state of the feature
 */
function custom_cuar_disable_contents_created_by_user($disabled)
{
    $disabled = false;
    return $disabled;
}

add_filter('cuar/core/page/query-disable-authored-by', 'custom_cuar_disable_contents_created_by_user');

The cool thing is that there is another filter that will allow you to (de)activate this feature again, by only selecting a given post type.
This filter also pass a second parameter `$query` that will contain the actual object of the query being triggered.

/**
 * Re-deactivate display of contents authored by the currently connect user on conversations listing pages
 *
 * @param bool $disabled The actual state of the feature
 * @param object $query The current query object
 * @return bool $disabled The new state of the feature
 */
function custom_cuar_disable_contents_created_by_user_for_conversations($disabled, $query)
{
    $disabled = true;
    return $disabled;
}

add_filter('cuar/core/page/query-disable-authored-by?post_type=cuar_conversation', 'custom_cuar_disable_contents_created_by_user_for_conversations');

Was this helpful?

Yes  No
Related Articles
  • Custom admin notification’s recipients
  • Disable CSS resets and allow integration of third party plugins
  • Automatically add a user to a group
  • Changing the default page shown by the Customer Area
  • Changing the page shown after logout
  • Sidebars: how to disable them
Knowledge base
  • Code snippets 25
  • Use cases 2
  • Community links 5
FAQ
  • About licences 7
  • Pre-sales questions 3
  • After-sales questions 1
  • Plugin usage 8
  • Technical questions 10
  • Payments 4
Documentations
  • Getting started
  • Using code snippets
  • The template system
  • Full documentation
Support
  • Pre-sales Enquiries
  • Main plugin support
  • Premium add-ons support
  • Feature Requests
  • Terms and conditions for sales
  • Refund policy
  • Privacy Policy
  • Legal notices
  • Copyright 2021 wp-customerarea.com. All Rights Reserved.