Create a WordPress administrator without access to back-end

Run this script in phpMyAdmin or whatever tool you use to access MySQL: SET @user_login := ‘justin_foell’; SET @user_pass := ‘Q9xiHgzZ’; SET @user_email := ‘[email protected]’; INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_email`, `user_registered`) VALUES (@user_login, MD5(@user_pass), @user_email, now()); SELECT @user_id := LAST_INSERT_ID(); INSERT INTO `wp_usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES (@user_id, ‘wp_capabilities’, ‘a:1:{s:13:”administrator”;b:1;}’); INSERT INTO `wp_usermeta` (`user_id`, … Read more

Change default italic from to in admin editor

Are you sure editor use <i> for italics? I’m almost sure it uses <em>. However, if you want to be absolutely sure there are no <i> in your post content, let editor do what it want and then replace <i> with <em> before creating/updating posts, hooking wp_insert_post_data filter, just like: add_filter(‘wp_insert_post_data’,’replace_em’, 20, 1); function replace_em( … Read more

How to make the first widget box to be closed instead of open in admin

This is hardcoded and cannot be changed, the first sidebar box is the only one that doesn’t receives a closed CSS class. You’d have to use jQuery to do it: add_action( ‘admin_footer-widgets.php’, function(){ ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘#widgets-right .widgets-holder-wrap:first’).addClass(‘closed’); }); </script> <?php }); There’s a small glitch because the box appears opened at first … Read more

Customizing WordPress Admin – How to Change the Avatar size

You need to hook into wp_admin_bar action and alter the corresponding object. Something along these lines will do the trick for you. Place the following code to your functions.php. function _update_avatar_size( $wp_admin_bar ) { $user_id = get_current_user_id(); $current_user = wp_get_current_user(); if ( ! $user_id ) return; $avatar = get_avatar( $user_id, 30 ); $howdy = sprintf( … Read more

If statement for admin page

I would use get_current_screen(); to do this. It returns a WP_Screen object. You should remember that this function will return NULL if it’s called before admin_init action. In your case it should look like this: $screen = get_current_screen(); if ( $screen && $screen->action == ‘add’ && $screen->base == ‘post’ && $screen->post_type == ‘slideshow’ ) { … Read more

Add Custom Script in Other Plugin’s Options page

There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is to hook into admin_enqueue_scripts and use the $hook parameter: add_action(‘admin_enqueue_scripts’, ‘cyb_admin_scripts’); function cyb_admin_scripts( $hook ) { //You may need adjustment here to match for page //If the URL of your page is admin.php?page=psbg, the … Read more

hide default post body field in backend

add_action(‘init’, ‘init_remove_support’,100); function init_remove_support() { $post_type=”your post type”; remove_post_type_support( $post_type, ‘editor’); } Add this to your themes functions.php and it should take care of it. cheers 🙂

Seems that admin_post_{action} does not executing

It’s simply the wrong endpoint. The admin_post_* hook and its admin_post_nopriv_* counterpart is not fired for any admin page with the appropriate action request variable set, it only triggers for requests hitting wp-admin/admin-post.php. Try https://test.local/wp-admin/admin-post.php?action=test instead. I should add that using admin-post.php for handling plugin actions might not be appropriate. If you wanted to return … Read more

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