• Resolved Jon Fuller

    (@garconis)


    Is there any built-in hook or function we could use, to basically hide this plugin notes column from ALL users (even other Admin users) except for one that we specify? Happy to add this via a PHP function snippet into our child functions.php… but didn’t know if there was anything built-in that would let me check if the user was a particular User ID (or based user email address), to then only show it for that user.

    Essentially: If NOT User ID of X, then hide it. Alternatively: If IS User ID of X, then show it. Either logic would be fine.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jon Fuller

    (@garconis)

    Update: looks like this should do the trick, but let me know if you notice anything wrong with it:
    https://gist.github.com/Garconis/d308efccf02e7376c59eecabb922970b

    Plugin Author jamiebergen

    (@jamiebergen)

    Hi Jon,

    What you have will get you almost there. However, it won’t hide the notes from unauthorized users on this page: /wp-admin/update-core.php. On that page, it renders a partial list of plugins that have updates available. Because there was no hook in WP core that would allow me to add an extra column on that page, I resorted to a JS solution. (You can see the commit where I added that feature here.)

    What I can do is add a filter to the plugin that will check whether to hide notes on the updates page. I did a quick test, and it should be pretty straightforward. Will that work for you?

    Thread Starter Jon Fuller

    (@garconis)

    I think that’d be great if you could add that. Thanks!

    Plugin Author jamiebergen

    (@jamiebergen)

    Hi Jon,

    I just released the update (v 1.2.6) that includes a hook so that you can specify which users can see plugin notes. The single hook plugin-notes-plus_hide_notes will control whether notes are visible on the main plugin page and the plugin updates page (/wp-admin/update-core.php). You can see a usage example in the plugin FAQs.

    Thanks for your patience with this!

    Jamie

    Thread Starter Jon Fuller

    (@garconis)

    Hey @jamiebergen … I’m just now getting around to testing this out. To test it with barebones code, I’ve implemented this function:

    function pnp_hide_notes( $hide_notes ) {
      
      	$hide_notes === true;
    
    	return $hide_notes;
    
    }
    add_filter( 'plugin-notes-plus_hide_notes', 'pnp_hide_notes' );

    But the Notes are still showing up. Any tips?

    Edit:

    Looks like I have to set it to be

    $hide_notes = false;

    With only a single equal sign. Does that sound right?

    Plugin Author jamiebergen

    (@jamiebergen)

    Yes, the single equal sign should do it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Function/hook to hide this column for all user except a certain one?’ is closed to new replies.