customization - Remove plugin settings from post creation page for a user role

I want to remove plugin settings from the bottom of the post creating page for a given user type. I want to remove the &

I want to remove plugin settings from the bottom of the post creating page for a given user type. I want to remove the "Plugin Organization" drop-down from the post creating page for a specific user type as shown in the image attached. Any code or plugin to do it?

I want to remove plugin settings from the bottom of the post creating page for a given user type. I want to remove the "Plugin Organization" drop-down from the post creating page for a specific user type as shown in the image attached. Any code or plugin to do it?

Share Improve this question asked May 27, 2020 at 16:36 shimiishimii 256 bronze badges 2
  • 1 You could check with the plugin's author, or look through their code to see whether they provided any hooks or ways to make their settings only appear for certain roles or capabilities. – WebElaine Commented May 27, 2020 at 18:24
  • @WebElaine I checked the documentation and didnt find anything, I sent them emails but didnt get a reply. Im trying to do it myself anyway – shimii Commented May 28, 2020 at 10:57
Add a comment  | 

1 Answer 1

Reset to default 0

As you've already done, the first step is to contact the plugin author directly.

If it's a plugin in the repo, you can also try asking the question on the plugin's support page there. Others in the community might see it and help, though that might take awhile. (If it's not on , there may still be public discussion or question boards available, so seek those out.)

The next thing to do is look through the code itself, to see if you can determine how this section is added to the editor, and whether the author provided some built-in way for it to be conditional.

If they did not build in a way to meet your needs, you can either code the change yourself or hire someone to do so. Then you will want to submit this change as a pull request to the author. Best case scenario, they will accept the change and it will become part of the plugin, so you can continue updating it. Worst case scenario, they never accept the change, and you will need to manually add in your change every time the plugin has an update available, or just maintain it as a fork (your own entirely separate version, where you need to make security and compatibility updates yourself) as long as you need the plugin.


More specifically:

You may be able to call remove_action() for that wppb_content_restriction_add_meta_box() function in your own custom plugin. You would then add a new add_action() with your conditional inside it - check if the user has a certain capability - and if it meets your criteria, then re-hook the function.

It depends on where they've hooked that function - you'll need to check, as it may not be init - but here's some code to get you started. (You'll need to determine what capability to check for so you're targeting the users you want; you'll need to check the hooks and priorities, but this should be close to what you're looking for.)

<?php
/* Plugin Name: Make Metabox Conditional
*/
// First, remove the action completely
add_action('init', 'wpse_367691_unhook', 11);
function wpse_367691_unhook() {
    remove_action('init', 'wppb_content_restriction_add_meta_box', 15);
}
// Now, add your own action which will include the conditional
add_action('init', 'wpse_367691_rehook, 20);
function wpse_367691_rehook() {
    // If the current user can publish Posts
    // (change this capability to target users who should see the box)
    if(current_user_can('publish_posts')) {
        wppb_content_restriction_add_meta_box();
    }
}
?>

You can then continue updating the original plugin - checking to make sure they don't change the name of their function or priority, which are likely not to change - and also keep this plugin which only makes the one function conditional.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742390220a4434863.html

相关推荐

  • customization - Remove plugin settings from post creation page for a user role

    I want to remove plugin settings from the bottom of the post creating page for a given user type. I want to remove the &

    8小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信