Programmatically Set First Image as Featured

Regarding the code you posted, I would say some things: you can avoid using 6 different actions because one is enough: ‘save_post’ is triggered everytime a post is created or updated you can drop globalize $post: ‘save_post’ will pass the post id, you can use it, in addition, preparing the function to receive an argument … Read more

username_exists() function can’t be access without logging in

When using Ajax API, and you want to make the ajax callback available for non-logged users, you need to add 2 actions, “wp_ajax_{$action}” and “wp_ajax_nopriv_{$action}”. Using only the first action, the callback will be called only for logged users, using only the second it will be called only for non-logged visitors. Try this: function check_username() … Read more

Custom post status not working

The post status values seems to be hardcoded in the core. Here’s the status box code for the edit screen: <span id=”post-status-display”> <?php switch ( $post->post_status ) { case ‘private’: _e(‘Privately Published’); break; case ‘publish’: _e(‘Published’); break; case ‘future’: _e(‘Scheduled’); break; case ‘pending’: _e(‘Pending Review’); break; case ‘draft’: case ‘auto-draft’: _e(‘Draft’); break; } ?> </span> … Read more

adding a filter to a shortcode?

You can change your code to this: <?php $shortcode = do_shortcode(‘[mingleforum]’); echo apply_filters(‘my_new_filter’,$shortcode); ?> and then you can interact with that filter add_filter(‘my_new_filter’,’my_new_filter_callback’); function my_new_filter_callback($shortcode){ //to stuff here return $shortcode; }

Remove Comments Metabox but still allow comments

Don’t remove this via CSS. The _POST part is also active and WP save the data! Use the hooks to remove meta boxes; code by scratch. function fb_remove_comments_meta_boxes() { remove_meta_box( ‘commentstatusdiv’, ‘post’, ‘normal’ ); remove_meta_box( ‘commentstatusdiv’, ‘page’, ‘normal’ ); // remove trackbacks remove_meta_box( ‘trackbacksdiv’, ‘post’, ‘normal’ ); remove_meta_box( ‘trackbacksdiv’, ‘page’, ‘normal’ ); } add_action( ‘admin_init’, … Read more

Plugin update error message

I know this is kind of a backwards way of doing it, but I suppose if you disable the possibility to upgrade the plugin, then you don’t need to worry about the plugin being overwritten. Change the plugin version number (in the plugins main file comment header) to something ridiculously high so it won’t recommend … Read more

How to add first name & last name to default registration form?

Add this code in functions.php add_action( ‘register_form’, ‘myplugin_register_form’ ); function myplugin_register_form() { $first_name = ( ! empty( $_POST[‘first_name’] ) ) ? trim( $_POST[‘first_name’] ) : ”; $last_name = ( ! empty( $_POST[‘last_name’] ) ) ? trim( $_POST[‘last_name’] ) : ”; ?> <p> <label for=”first_name”><?php _e( ‘First Name’, ‘mydomain’ ) ?><br /> <input type=”text” name=”first_name” id=”first_name” … Read more