- This topic has 3 replies, 2 voices, and was last updated 2 years, 5 months ago by David.
-
AuthorPosts
-
November 5, 2021 at 3:36 am #1992336eduard sans
Hi there again,
So this is the last piece of code that I need to clear out of the system, and as much as it feels like a very simple function, I really have no idea what to do. Here’s the warning:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'hide_custom' not found or invalid function name in /home/esans/bundle2.eduardosans.com/wp-includes/class-wp-hook.php on line 303
it is displayed in the wordpress panel.
And again, after clearing plugins, elements and custom code, what triggers this error is this piece of code:if( !current_user_can( 'edit_plugins' ) ) : function hide_custom() { echo '<style> .toplevel_page_generateblocks, /* Generateblocks menu */ .hide-if-no-customize, /* Personaliza */ .menu-icon-appearance li:nth-child(2), /* Temas */ .menu-icon-appearance li:last-child, /* GeneratePress */ #sln-setting-error, /* "This plugin needs a valid license" */ .sln-calendar-plugin-update-notice, /* "Your subscription is renewed" */ .nav-tab.nav-tab-gcalendar, /* Google Calendar */ .post-type-sln_attendant a.page-title-action, /* Añadir asistentes */ .post-type-sln_service a.page-title-action, /* Añadir servicios */ .post-type-sln_attendant .clone a /* Clonar asistentes o servicios */ {display:none !important;} </style>'; } endif; add_action('admin_head', 'hide_custom');
Basically a code to hide certain buttons for a certain type of users. I think it is pretty literal.
Any thoughts? I really don’t know where else to goThanks again!
November 5, 2021 at 5:12 am #1992443DavidStaffCustomer SupportHi there,
try changing the code so the
current_user_can
condition is within the function:function hide_custom() { if( !current_user_can( 'edit_plugins' ) ) { echo '<style> .toplevel_page_generateblocks, /* Generateblocks menu */ .hide-if-no-customize, /* Personaliza */ .menu-icon-appearance li:nth-child(2), /* Temas */ .menu-icon-appearance li:last-child, /* GeneratePress */ #sln-setting-error, /* "This plugin needs a valid license" */ .sln-calendar-plugin-update-notice, /* "Your subscription is renewed" */ .nav-tab.nav-tab-gcalendar, /* Google Calendar */ .post-type-sln_attendant a.page-title-action, /* Añadir asistentes */ .post-type-sln_service a.page-title-action, /* Añadir servicios */ .post-type-sln_attendant .clone a /* Clonar asistentes o servicios */ {display:none !important;} </style>'; } } add_action('admin_head', 'hide_custom');
November 5, 2021 at 6:13 am #1992512eduard sansomg David, I shit you not, you guys are the best when it comes to support. It worked!! Thank you so much! 🙂
November 5, 2021 at 6:56 am #1992555DavidStaffCustomer SupportHaha 🙂 Glad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.