_x('Name Prefix', 'form label', 'anno'), '_anno_suffix' => _x('Name Suffix', 'form label', 'anno'), '_anno_degrees' => _x('Degrees', 'form label', 'anno'), '_anno_affiliation' => _x('Affiliation', 'form label', 'anno'), ); /** * Adds the menu page to WP. */ function anno_add_profile() { add_users_page( _x('Annotum Profile', 'admin page title', 'anno'), _x('Annotum Profile', 'admin sidebar menu title', 'anno'), 'read', 'anno-profile', 'anno_profile' ); } add_action('admin_menu', 'anno_add_profile'); /** * User profile markup for Annotum specific items */ function anno_profile() { global $anno_user_meta; $current_user = wp_get_current_user(); ?>

$label) { $meta_val = get_user_attribute($current_user->ID, $key, true); ?>
first_name); ?> ()
last_name); ?> ()

$label) { if (isset($_POST[$meta_key])) { $value = trim($_POST[$meta_key]); } else { $value = ''; } update_user_attribute(absint($_POST['user_id']), $meta_key, $value); } wp_redirect(admin_url('users.php?page=anno-profile&update=true')); die(); } break; default: break; } } } add_action('init', 'anno_profile_request_handler', 0); /** * Takes a snapshot of author/co-authors user data and stores it in post data * Only stores on publish and does not overwrite existing. */ //TODO Order function anno_users_snapshot($post_id, $post) { if ($post->post_status == 'publish' && $post->post_type == 'article') { $authors = anno_get_authors($post->ID); $author_meta = get_post_meta($post_id, '_anno_author_snapshot', true); if (!is_array($author_meta)) { $author_meta = array(); } foreach ($authors as $author_id) { if (array_key_exists($author_id, $author_meta)) { continue; } $author = get_userdata($author_id); if ($author) { $author_meta[$author->ID] = array( 'id' => $author->ID, 'surname' => $author->last_name, 'given_names' => $author->first_name, 'prefix' => get_user_attribute($author->ID, '_anno_prefix', true), 'suffix' => get_user_attribute($author->ID, '_anno_suffix', true), 'degrees' => get_user_attribute($author->ID, '_anno_degrees', true), 'affiliation' => get_user_attribute($author->ID, '_anno_affiliation', true), 'bio' => $author->user_description, 'email' => $author->user_email, 'link' => $author->user_url, ); } else { delete_post_meta($post->ID, '_anno_author_'.$author_id); } } update_post_meta($post_id, '_anno_author_snapshot', $author_meta); } } add_action('wp_insert_post', 'anno_users_snapshot', 10, 2); ?>