Admin area ‘toggle’ w/ cookie

Checkout the HTML for a WP meta-box : <div id=”my_div” class=”postbox “> <div class=”handlediv” title=”Click to toggle.”><br></div> <h3 class=”hndle”><span>title</span></h3> <div class=”inside”> … </div> </div> If you follow that structure (and CSS classes) in your custom meta-box, the toggle will work.

New users must comment when requesting username

You can use a captcha plugin that requires users to type a short phrase or random letters in order to register on your site. An example of one of these plugins is the WP-reCAPTCHA, found at: http://wordpress.org/extend/plugins/wp-recaptcha/ Or you can use a plugin such as CIMY User Extra Fields to add fields to a user … Read more

In administration, how do I display comments of a certain user?

Afaik, there’s no straight forward way for this. You’d have to extend the WP_List_Table and add an extra column. This would be an example function: function wpse_get_comments_by_user( $user_ID ) { global $wpdb; $rows = $wpdb->query( $wpdb->prepare( ” SELECT * FROM %s WHERE user_id = %d ” ,$wpdb->comments ,(int) $user_ID ) ); return $rows; } The … Read more

Change the Default Pages Menu View in wp-admin

[Update] Answer rewritten, based on this other Q&A. To achieve this: Use this code: add_filter( ‘custom_menu_order’, ‘wpse_48933_submenu_order’ ); function wpse_48933_submenu_order( $menu_ord ) { global $submenu; // Enable the next line to inspect the $submenu values // echo ‘<pre>’.print_r($submenu,true).'</pre>’; $arr = array(); $arr[] = $submenu[‘edit.php?post_type=page’][10]; $arr[] = $submenu[‘edit.php?post_type=page’][5]; $submenu[‘edit.php?post_type=page’] = $arr; return $menu_ord; }

wp_dropdown_pages() in theme admin page

grrr.really annoying, 2hrs and then i found it myself $args = array( ‘echo’ => 1, ‘selected’ => $home_galleryselect, ‘name’ => ‘theme_option[home_galleryselect]’); wp_dropdown_pages($args);

Adding markup to column text in “Edit Pages” admin page

I found that there is a filter, manage_posts_columns (and a related manage_pages_columns), that lets you modify the column headers on the “All Posts” admin screen. Using this filter is pretty simple, as the filtering function takes in an associative array with the short name of the column as a key and the heading as the … Read more

How To Create User Specific Admin User Pages?

You can add a new page using add_(sub)menu_page();. WordPress is pretty kind in this case and offers tons of hooks, filters and higher level API functions that help you going around this. Let’s just use add_users_page(); and hook into admin_menu. Example plugin It adds an admin page that has the user_login as slug. Simply drop … Read more

Create a Meta Box in the Admin User Screen?

Well, as you already know, meta boxes are for post types only… What you can do is to customize the heck out of that screen. What follows is the code I used on a client’s custom theme. Originally, it was used with the action hook admin_print_scripts-profile.php (which could also be added bellow). /functions.php: add_action( ‘admin_print_scripts-user-new.php’, … Read more

Restrict dashboard access for specific user roles to specific actions

This is how I ended up solving this issue. Originally I used this code for the link to delete an individual post: <?php if( !(get_post_status() == ‘trash’) ) : ?> <a class=”delete-post” onclick=”return confirm(‘Are you sure you wish to delete post: <?php echo get_the_title() ?>?’)”href=”https://wordpress.stackexchange.com/questions/78144/<?php echo get_delete_post_link( get_the_ID() ); ?>”>Delete</a> <?php endif; ?> After checking … Read more

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