Month: February 2012

  • Users

    Adding and using custom user profile fields

    Function Reference/update user meta « WordPress Codex

    <?php
    /* =USER Extra Fields (Pilot check dates) */
    // the_author_meta( $meta_key, $user_id );
    add_action( 'show_user_profile', 'nwa_show_extra_profile_fields' );
    add_action( 'edit_user_profile', 'nwa_show_extra_profile_fields' );
    
    function nwa_show_extra_profile_fields( $user ) { ?>
    
    	<h3>Pilot Checks</h3>
    
    	<table class="form-table">
    		<tr>
    			<td>
    				<span class="description">Dates when last done:</span>
    			</td>
    			<th><label for="pilot_checkride">135 Checkride</label></th>
    			<td>
    				<input type="text" name="pilot_checkride" id="pilot_checkride" value="<?php echo esc_attr( get_the_author_meta( 'pilot_checkride', $user->ID ) ); ?>" class="regular-text" /><br />
    			</td>
    		</tr>
    		<tr>
    			<th><label for="pilot_med">Class 2 Medical</label></th>
    			<td>
    				<span class="description">Dates when last done:</span>
    				<input type="text" name="pilot_med" id="pilot_med" value="<?php echo esc_attr( get_the_author_meta( 'pilot_med', $user->ID ) ); ?>" class="regular-text" /><br />
    			</td>
    		</tr>
    		<tr>
    			<th><label for="pilot_osa">OSA</label></th>
    			<td>
    				<input type="text" name="pilot_osa" id="pilot_checkride" value="<?php echo esc_attr( get_the_author_meta( 'pilot_osa', $user->ID ) ); ?>" class="regular-text" /><br />
    			</td>
    		</tr>
    	</table>
    <?php }
    
    add_action( 'personal_options_update', 'nwa_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'nwa_save_extra_profile_fields' );
    
    function nwa_save_extra_profile_fields( $user_id ) {
    
    	if ( !current_user_can( 'edit_user', $user_id ) )
    		return false;
    
    	/* Copy and paste this line for additional fields. Make sure to change to the field ID. */
    	update_user_meta( $user_id, 'pilot_checkride', $_POST['pilot_checkride'] );
    	update_user_meta( $user_id, 'pilot_med', $_POST['pilot_med'] );
    	update_user_meta( $user_id, 'pilot_osa', $_POST['pilot_osa'] );
    }
    ?>
    
  • Embed

    Google author:

    How To Implement Rel=Author


    http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1408986

    http://alisothegeek.com/2013/01/adding-oembed-handlers-to-wordpress/

  • Date

    HV:

    // Display mp3 five days after airdate
    if ( strtotime( '-5 days' ) > strtotime( $airdate ) )
        $audio_url = 'http://hearvox.com/episode/cast/' . $airyr . '/' . $fileID . '.mp3';
    
    <?php
    $d = new DateTime( '2010-01-08' );
    $d->modify( 'first day of next month' );
    echo $d->format( 'F' ), "\n";
    ?>
    

    http://www.php.net/manual/en/datetime.modify.php

    http://www.php.net/manual/en/datetime.diff.php

  • hNews

    testing hNews plugin fields

    [[code]hnews_meta[/code]]

    [/js]