Archived topic
Another php notice triggered from functions.php
3 replies · Started by eduard sans on November 5, 2021
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 go
Thanks again!
Hi 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');
omg David, I shit you not, you guys are the best when it comes to support. It worked!! Thank you so much! :)
Haha :) Glad to be of help!