Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Extra user profile fields
- Plugin URI: http://gcps.org.au
- description: >-
- a plugin to Edit a Users Profile
- Version: 1.0
- Author: Rhonda Ramadge
- Author URI: http://rhondaramadge.com
- License: GPL2
- */
- //add_action( 'show_user_profile', 'extra_user_profile_fields' );
- add_action( 'edit_user_profile', 'extra_user_profile_fields' );
- function extra_user_profile_fields( $user ) { ?>
- <h3><?php _e("Extra profile information", "blank"); ?></h3>
- <table class="form-table">
- <tr>
- <th><label for="pin"><?php _e("Pin"); ?></label></th>
- <td>
- <input type="text" name="pin" id="pin" value="<?php echo esc_attr( get_the_author_meta( 'pin', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Pin Number."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="street-address"><?php _e("Street-Address"); ?></label></th>
- <td>
- <input type="text" name="street-address" id="street-address" value="<?php echo esc_attr( get_the_author_meta( 'street-address', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Street address."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="suburb"><?php _e("Suburb"); ?></label></th>
- <td>
- <input type="text" name="suburb" id="suburb" value="<?php echo esc_attr( get_the_author_meta( 'suburb', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Suburb."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="postcode"><?php _e("Postcode"); ?></label></th>
- <td>
- <input type="text" name="postcode" id="postcode" value="<?php echo esc_attr( get_the_author_meta( 'postcode', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Postcode."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="phone"><?php _e("Phone"); ?></label></th>
- <td>
- <input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Phone Number."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="mobile"><?php _e("Mobile"); ?></label></th>
- <td>
- <input type="text" name="mobile" id="mobile" value="<?php echo esc_attr( get_the_author_meta( 'mobile', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Mobile number."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="president-year"><?php _e("President-year"); ?></label></th>
- <td>
- <input type="text" name="president-year" id="president-year" value="<?php echo esc_attr( get_the_author_meta( 'president-year', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("President Year."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="secretary-year"><?php _e("Secretary-year"); ?></label></th>
- <td>
- <input type="text" name="secretary-year" id="secretary-year" value="<?php echo esc_attr( get_the_author_meta( 'secretary-year', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Secretary Year."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="competition-secretary-year"><?php _e("Competition-secretary-year"); ?></label></th>
- <td>
- <input type="text" name="competition-secretary-year" id="competition-secretary-year" value="<?php echo esc_attr( get_the_author_meta( 'competition-secretary-year', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Competition Secretary Year."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="treasurer-year"><?php _e("Treasurer-year"); ?></label></th>
- <td>
- <input type="text" name="treasurer-year" id="treasurer-year" value="<?php echo esc_attr( get_the_author_meta( 'treasurer-year', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Treasurer Year."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="committee-member-year"><?php _e("Committee-member-year"); ?></label></th>
- <td>
- <input type="text" name="committee-member-year" id="committee-member-year" value="<?php echo esc_attr( get_the_author_meta( 'committee-member-year', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Committee Member Year."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="other-roles"><?php _e("Other-Roles"); ?></label></th>
- <td>
- <textarea type="text" name="other-roles" id="other-roles" class="regular-text"><?php echo esc_attr( get_the_author_meta( 'other-roles', $user->ID ) ); ?></textarea><br />
- <span class="description"><?php _e("Other Roles."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="joining-date"><?php _e("Joining-date"); ?></label></th>
- <td>
- <input type="text" name="joining-date" id="joining-date" value="<?php echo esc_attr( get_the_author_meta( 'joining-date', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Joining Date Must be entered as yearmonthday (no spaces,/ or.) e.g. 29/6/2018 entered as 20180629"); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="year-left"><?php _e("Year left"); ?></label></th>
- <td>
- <input type="text" name="year-left" id="year-left" value="<?php echo esc_attr( get_the_author_meta( 'year-left', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Year Left"); ?></span>
- </td>
- </tr>
- <tr>
- <th><label FOR="fees-paid">Are Fees Paid</label></th>
- <td>
- <?php $status = get_the_author_meta( 'fees-paid', $user->ID ); ?>
- <input TYPE="radio" name="fees-paid" value="yes" <?php checked( $status, 'yes' ); ?> /> Yes<br />
- <input TYPE="radio" name="fees-paid" value="no" <?php checked( $status, 'no' ); ?> /> No<br />
- <span CLASS="description">Have fees been paid.</span>
- </td>
- </tr>
- <tr>
- <th><label for="life-member"><?php _e("Life Member"); ?></label></th>
- <td>
- <input type="checkbox" name="life-member" id=" life-member " value="yes" <?php if (esc_attr( get_the_author_meta( "life-member", $user->ID )) == "yes") echo "checked"; ?> /><label for="life-member "><?php _e("Life Member"); ?></label><br />
- </td>
- </tr>
- <tr>
- <th><label for="comments"><?php _e("Comments"); ?></label></th>
- <td>
- <textarea type="text" name="comments" id="comments" class="regular-text"><?php echo esc_attr( get_the_author_meta( 'comments', $user->ID ) ); ?></textarea><br />
- <span class="description"><?php _e("Comments."); ?></span>
- </td>
- </tr>
- </table>
- <?php }
- add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
- add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
- function save_extra_user_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) ) {
- return false;
- }
- update_user_meta( $user_id, 'pin', $_POST['pin'] );
- update_user_meta( $user_id, 'street-address', $_POST['street-address'] );
- update_user_meta( $user_id, 'suburb', $_POST['suburb'] );
- update_user_meta( $user_id, 'postcode', $_POST['postcode'] );
- update_user_meta( $user_id, 'phone', $_POST['phone'] );
- update_user_meta( $user_id, 'mobile', $_POST['mobile'] );
- update_user_meta( $user_id, 'president-year', $_POST['president-year'] );
- update_user_meta( $user_id, 'secretary-year', $_POST['secretary-year'] );
- update_user_meta( $user_id, 'competition-secretary-year', $_POST['competition-secretary-year'] );
- update_user_meta( $user_id, 'treasurer-year', $_POST['treasurer-year'] );
- update_user_meta( $user_id, 'committee-member-year', $_POST['committee-member-year'] );
- update_user_meta( $user_id, 'joining-date', $_POST['joining-date'] );
- update_user_meta( $user_id, 'fees-paid', $_POST['fees-paid'] );
- update_user_meta( $user_id, 'life-member', $_POST['life-member'] );
- update_user_meta( $user_id, 'comments', $_POST['comments'] );
- update_user_meta( $user_id, 'other-roles', $_POST['other-roles'] );
- update_user_meta( $user_id, 'year-left', $_POST['year-left'] );
- }
- /**
- * Change inline eit for a specific custom field to a prefilled drop down
- *
- * @param $data array
- * @param $column AC\Column
- *
- * @return mixed
- */
- function my_acp_custom_field_editing_selectbox( $data, $column ) {
- if ( $column instanceof ACP\Column\CustomField ) {
- if ( 'fees-paid' === $column->get_meta_key() ) {
- $data['type'] = 'select';
- $data['options'] = array(
- 'yes' => 'Yes',
- 'no' => 'No',
- );
- }
- }
- return $data;
- }
- add_filter( 'acp/editing/view_settings', 'my_acp_custom_field_editing_selectbox', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement