Support » Plugin: BuddyPress Docs » Attachments to be viewable by loggedin users by default

  • Resolved Robert Stevens

    (@zoeitsolutions)


    Hi,

    I have search the forums and found some relating topics but none of the solutions worked for me. As the title suggests I am trying to set the default “read” permission for the attachment to be for logged in users.

    I have tried to hook into bp_docs_get_default_access_options but then the “loggedin” option is set for every field, and I only want it show for the read setting.

    THanks.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author David Cavins

    (@dcavins)

    Hi, you can find the code to make that change in this response:
    https://wordpress.org/support/topic/how-do-i-set-the-default-permissions-for-a-doc/

    Look for the link to the GitHub gist.

    Best,

    -David

    Thread Starter Robert Stevens

    (@zoeitsolutions)

    Hi David,

    Thanks, I have tried to use the gist code via functions.php, but it immediately causes a fatal error on my site.

    If that solution still applies, I will check the error log to see why it’s causing the error.

    Thanks

    Plugin Author David Cavins

    (@dcavins)

    Hi Robert-

    Yes, the gist is still correct.
    https://gist.github.com/dcavins/0f9943c2e2dd506afc58c3b56f8013c8

    You can put it in your bp-custom file or wherever you keep customizations. If there’s a fatal error, then you’ll need to see where the problem lies, because the gist doesn’t have a fatal error baked in (it works on my test site as expected).

    Thread Starter Robert Stevens

    (@zoeitsolutions)

    Hi David,

    Ok. It seems that code was already added to our bp-custom.php and that’s why it was causing the fatal error.

    
    add_filter( 'bp_docs_get_default_access_options', 'my_change_docs_default_access_levels' );
    function my_change_docs_default_access_levels( $defaults ) {
      $defaults['read'] = 'anyone';
      return $defaults;
    }
    

    That would mean that the code should be working, but the read option still says “doc author only” as the default option.

    The bp-custom file is kept in /plugins folder.

    Why would it not be working?

    Tx, Robert

    Plugin Author David Cavins

    (@dcavins)

    I really couldn’t say (and doc_author isn’t the default setting–so it’s being modified by some code you’ve added somwehere). If I were you, I’d search your whole code base for other instances of the string bp_docs_get_default_access_options and see if any other filters are being applied.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Attachments to be viewable by loggedin users by default’ is closed to new replies.