current_user_can(‘Administrator’) does not return true in multisite if user is Administrator but NOT Super Admin

I would agree that current_user_can(‘Administrator’) should return true for the user. However, current_user_can is primarily intended to check for capabilities, which is generally a more robust check to be making. I’d suggest something like this (untested): if ( current_user_can( ‘activate_plugins’ ) && ! current_user_can( ‘update_core’ ) ) { //… } So this is checking if … Read more

How do I fix “You are not allowed to edit this item.” for Admins on existing posts?

I fixed this by editing /wp-includes/capabilities.php The code was function current_user_can( $capability ) { $current_user = wp_get_current_user(); if ( empty( $current_user ) ) return false; $args = array_slice( func_get_args(), 1 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( $current_user, ‘has_cap’ ), $args ); } and I changed it to function current_user_can( … Read more

Is it possible to hook AJAX to UPDATE-button?

If all you’re wanting to do is save extra post data you should not need jquery or custom ajax. WordPress has a built in action you can use to achieve this same thing. add_action( ‘save_post’, ‘save_more_post_meta’ ); function save_more_post_meta( $post_id ) { //save stuff here } If you need help with saving specifics i’ll need … Read more

Adding Field to Profile “Name”

check out my older article HOW TO ADD WORDPRESS AUTHOR BIO & PROFILE PAGE https://phirebase.com/blog/how-to-add-author-bio-profile-page/ just short example to add Twitter and Facebook fields: function my_new_contactmethods( $contactmethods ) { // Add Twitter $contactmethods[‘twitter’] = ‘Twitter’; //Add Facebook $contactmethods[‘facebook’] = ‘Facebook’; return $contactmethods; } add_filter(‘user_contactmethods’,’my_new_contactmethods’,10,1); Single loop <?php the_author_meta(‘facebook’); ?> – show facebook name <?php the_author_meta(‘twitter’); … Read more

Trying to add admin file upload form plugin

Turns out the code is correct, the problem is the tutorial site I copy/pasted from was using weird, non standard space characters instead of normal spaces. I replaced the “fake spaces” with “normal spaces” and now everything works. In order to debug this I needed to look at the Apache error log rather than the … Read more

How to change redirect after moving a page to trash?

Hook into load-{screen_id} and check if the $_GET[‘trashed’] variable is 1 or above. add_action(‘load-edit.php’,’wpse_trashed_redirect’); function wpse_trashed_redirect(){ $screen = get_current_screen(); if(‘edit-page’ == $screen->id){ if( isset($_GET[‘trashed’]) && intval($_GET[‘trashed’]) >0){ $redirect = add_query_arg(array(‘page’=>’custom_page_oder’, ‘trashed’ => false, ‘ids’ => false )); wp_redirect($redirect); exit(); } } } This works – and I’m not aware of a better way of doing … Read more

What filter/action hook can I use to add a few links to the admin comments page?

There is no hook. The only place to print something to the screen is at the beginning of the field where $author_url = get_comment_author_url(); is executed. Sample: add_action( ‘load-edit-comments.php’, ‘wpse_64737_comment_actions’ ); function wpse_64737_comment_actions( $url=”” ) { if ( ‘load-edit-comments.php’ === current_filter() ) { add_filter( ‘get_comment_author_url’, __FUNCTION__ ); return; } echo ‘<p>Output in the Author field!</p>’; … Read more

Default, locked sorting of posting fields

I can answer the last part: “I also want the excerpt-field to be above the content-field. Is all this possible?” The only way to move anything above the content field is via JavaScript–there are no php hooks or filters up there. It’s kind of a lame workaround because you can usually see (visually) the jump … Read more