Blog

  • 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]

  • Storify

    listing them in some what the order i encountered them (not order of importance), and much from the pov of a new user:

    STUCK IN CREATION: i’m a new user. i hit “Create”, then “Save Now”, “Sign up with FB” (or “Sign Up” then “Sign up with FB”).

    once logged in, tho, it still says “Sign Up” and “Login” on up-right, w/ no “Back to Profile” or User links. so i’m stuck, no way to get to my settings, profile, logout. see screenshot, the story was saved, so i’m logged in, but the top button still wants me to “Login ”

    DRAFTS: once you’ve signed up and come back to the site, the first thing a user might want to do is work on Draft(s). but via site pages have no obvious link to the users stories. the top-right User select-menu lists has “Settings”, “Subscriptions”, etc. but not “Profile”. that’s b/c the menu itself (the username/gravatar) is the link to “Profile”.

    generally, tho, while a select menu can have links, it isn’t itself a link. so it’s a discoverability issue. and your Edit screen User select-menu is just the opposite: the username is NOT hot and the options DO list a Profile link.

    PROFILE: in fact the user “profile” page is not named “profile” anywhere. there is no link on the text “Profile” anywhere (except Edit). the Settings page has “Settings” heading text and a “/settings” URL, but a user’s profile has no indication “profile” is the term for that page.

    a side terminology note, in the Feedback section, you often refer to Settings->Profile. this implies a relationship that doesn’t exist, ie, the “Settings” page does not have a subset/child Settings->”Profile” page. (more…)

  • UNIX

    change prompt:
    PS1='[${USER}@${HOSTNAME} ${PWD}]$ '

  • Here’s Lookin’

    Here’s Lookin’ @ You, Niño #casablanca 1942-11_26 🙂
    heres-lookin-you-nino-casablanca-1942-11_26

    By default that slug is version of the post’s title, processed by WordPress to use only lower-case alphanumeric characters, also underscore and the dash (if not at the beginning or end of the title). WordPress takes the title and:
    * Converts upper-case letters to lower-case.
    * Converts accented letters to their unaccented equivalent.
    * Removes all punctuation and symbols, except underscore and dash.
    * Removes leading and trailing dash.
    * Replaces space(s) with a dash.

    So a slug allows lower-case alphanumeric characters, underscore, and dash ([a-z], [0-9], [_], [-]).
    * Allow underscore (_),
    * Allow dash (-), unless leading or trailing.

    title, slug, and (working) permalink:
    12345678901234567890123456789012345678901234567890123456789012345678901234567890
    12345678901234567890123456789012345678901234567890123456789012345678901234567890
    https://dev.pubmedia.us/2012/01/
    12345678901234567890123456789012345678901234567890123456789012345678901234567890/

    Page slugs shouldn’t be numeric-only.

    http://core.trac.wordpress.org/ticket/14238

    Here’s Lookin’@You,_Niño #casablanca 1942/11/26 🙂
    heres-lookinyou_nino-casablanca-19421126

    Here’s Lookin’@-You,_Niño #casablanca 1942/11/26 🙂
    heres-lookinyou_nino-casablanca-19421126

    Here’s Lookin’ @ You,_Niño #casablanca 1942/11/26 🙂
    heres-lookin-you_nino-casablanca-19421126

    Here’s Lookin’ @ You, Niño #casablanca 1942/11_26 🙂
    heres-lookin-you-nino-casablanca-194211_26

  • Revision Management

    http://codex.wordpress.org/User:MichaelH/Testing/Revisions

    http://codex.wordpress.org/Revision_Management

    http://pubmedia.us/word/2010/03/wp-revs/

    http://codex.wordpress.org/Post_Types#Revisions
    Revisions
    A “revision” is used to hold draft posts as well as any past revisions of existing posts or pages. These are basically identical to the main post/page that they are for, but have that post/page as their parent.

    http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions

    register_post-type()
    post type is a native or “built-in” post_type
    this is a built-in native post type (post, page, attachment, revision, nav_menu_item)

    wp-includes/post.php

    add_post_type_support()

    Disable post revisions in WordPress 3.0

    OPTIMIZE TABLE wp_posts;

    http://codex.wordpress.org/Function_Reference/wp_text_diff

    wp_get_post_revisions()

    wp_delete_post_revision()

    $return[‘post_name’] = $autosave ? “$post[ID]-autosave” : “$post[ID]-revision”;

    define( ‘AUTOSAVE_INTERVAL’, 120 );

    http://wordpress.org/extend/plugins/skip-identical-revisions/