Skip to:
Content
Pages
Categories
Search
Top
Bottom

About bp_nouveau_current_user_can


  • Joseph G.
    Participant

    @dunhakdis

    Anyone knows how to filter the “bp_nouveau_current_user_can” function with out affecting the previous set filter?

    
    // return is being overwritten by the the next filter. Returns true instead of false.
    add_filter("bp_nouveau_current_user_can", function( $is_loggedin, $cap, $uid ){
        if ( $cap === "publish_activity" ) {
            return false;
        }
        return $is_loggedin;
    }, 20, 3);
    
    // overwiting previous filter.
    add_filter("bp_nouveau_current_user_can", function( $is_loggedin, $cap, $uid ){
        if ( $cap === "comment_activity" ) {
            return true;
        }
        return $is_loggedin;
    }, 20, 3);

    Would be great if we can check if current user can do things in specific components.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Why not just combine them?

        if ( $cap === "publish_activity" ) {
            return false;
        } 
        elseif ( $cap === "comment_activity" ) {
            return true;
        }

    Joseph G.
    Participant

    @dunhakdis

    Hi @shanebp,

    Thanks for taking your time to reply. I really appreciate it. However, the result stays the same.

    “publish_activity” would still return true if there is a “comment_activity”. I think its because they’re using the same filter.

    Maybe I’m missing something?

    Would be great if there is something like “bp_nouveau_current_user_can_{$capabilities}” to isolate the filter accordingly.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar