Change default admin page for specific role(s)

In your theme’s functions.php: function hide_the_dashboard() { global $current_user; // is there a user ? if ( is_array( $current_user->roles ) ) { // substitute your role(s): if ( in_array( ‘custom_role’, $current_user->roles ) ) { // hide the dashboard: remove_menu_page( ‘index.php’ ); } } } add_action( ‘admin_menu’, ‘hide_the_dashboard’ ); function your_login_redirect( $redirect_to, $request, $user ) { … Read more

Load js/css files only on specific admin UI pages

The right hooks // Use both for scripts & styles *) wp_enqueue_scripts // (for the frontend) login_enqueue_scripts // (for the login screen) admin_enqueue_scripts // (for the admin dashboard) *) Read this article @wpdevel. Further reading in the Codex about the three hooks admin_menu network_admin_menu user_admin_menu On the admin_enqueue_scripts hook, you have an argument as well: … Read more

Admin settings update updating every time home page is hit?

A much better hook to use would the the update_option_{option_name} dynamic hook, which only runs after your specific option has been updated. So something like: add_action(‘update_option_woocommerce_email_send_time’, ‘send_time’) function update_send_time() { // Add code here to update cron job } The only problem you’ll get here is that scheduling the cron job for a time earlier … Read more

What is an alternative method to the WordPress private _doing_it_wrong() function

What is an alternative method to the WordPress private _doing_it_wrong() function? There’s no way that WordPress is ever going to get rid of the _doing_it_wrong() function, so it’s perfectly safe to use it. But if for some reason you don’t want to use it because it’s marked private, then you could create a plugin that … Read more

Custom action button in Gutenberg editor (post_submitbox_misc_actions – equivalent)

wp_enqueue_script( ‘some-slug’, ‘/path/to/script.js’, array( ‘wp-edit-post’, ‘wp-plugins’, ‘wp-i18n’, ‘wp-element’ ), ‘0.1’ ); script.js: var el = wp.element.createElement; var __ = wp.i18n.__; var registerPlugin = wp.plugins.registerPlugin; var PluginPostStatusInfo = wp.editPost.PluginPostStatusInfo; var TextControl = wp.components.TextControl; function MyPostStatusInfoPlugin({}) { return el( PluginPostStatusInfo, { className: ‘my-post-status-info’ }, el( TextControl, { name: ‘my_edit_summary’, label: __( ‘Edit summary’ ), help: __( ‘Briefly … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)