• Resolved marikamitsos

    (@marikamitsos)


    WP v6.6 – Plugin Notes Plus v1.2.7

    On the FAQ you post the following code but cannot see where to add the users names (eg: John AND Mike)

    function pnp_hide_notes( $hide_notes ) {
    
        // logic to set $hide_notes to TRUE or FALSE
    
        return $hide_notes;
    
    }
    add_filter( 'plugin-notes-plus_hide_notes', 'pnp_hide_notes' );

    Can you please help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author jamiebergen

    (@jamiebergen)

    Hi,

    The comment that says “logic to set $hide_notes to TRUE or FALSE” is where you would write some code to determine whether to hide the plugin notes. By default any user who can view the plugins page (typically, this is any user with the Administrator role) can view and update plugin notes.

    If you want to hide the plugin notes from a specific user, you can write something like below. By default, plugin notes are not hidden, but they are hidden from the user with ID 6 in this example.

    I tested this code on WP v6.6 – Plugin Notes Plus v1.2.7 and confirmed that it’s working.


    $hide_notes = FALSE;

    $user_id = get_current_user_id();

    if ( 6 === $user_id ) {
    $hide_notes = TRUE;
    }

    return $hide_notes;
    Thread Starter marikamitsos

    (@marikamitsos)

    @jamiebergen Thank you for your reply.

    It is now clear to me about one user.

    How can I hide them from more than one users? (I use it on a site and I am administrator 3)

    Could this be the solution?

    function pnp_hide_notes( $hide_notes ) {

    $hide_notes = TRUE;
    $user_id = get_current_user_id();
    if ( 3 === $user_id ) {
    $hide_notes = FALSE;
    }
    return $hide_notes;

    }
    add_filter( 'plugin-notes-plus_hide_notes', 'pnp_hide_notes' );

    We have created a role that can see the plugins page but not edit them (de/activate, delete/install). How can we hide the notes from that role?

    Plugin Author jamiebergen

    (@jamiebergen)

    The code you wrote will hide plugin notes from all users except for the user with ID 3. To hide notes from specific user roles, I would look at this page for how to check for specific user roles. Looks like you’re on the right track.

    Thread Starter marikamitsos

    (@marikamitsos)

    Thank you @jamiebergen

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