Skip to main content

It is for displaying and updating the custom user meta data.

// Hooks near the bottom of profile page (if current user)
add_action('show_user_profile', 'custom_user_profile_fields');

// Hooks near the bottom of the profile page (if not current user)
add_action('edit_user_profile', 'custom_user_profile_fields');

// @param WP_User $user
function custom_user_profile_fields( $user ) {
?>
    <table class="form-table">
        <tr>
            <th>
                <label for="code"><?php _e( 'App Store Link to VR App' ); ?></label>
            </th>
            <td>
                <input type="text" name="user_app_store_link" id="user_app_store_link" value="<?php echo esc_attr( get_the_author_meta( 'user_app_store_link', $user->ID ) ); ?>" class="regular-text" />
            </td>
        </tr>
       
        <tr>
            <th>
                <label for="code"><?php _e( 'How did you find Vertebrae?' ); ?></label>
            </th>
            <td>
                <input type="text" name="find_vertebrae" id="find_vertebrae" value="<?php echo esc_attr( get_the_author_meta( 'find_vertebrae', $user->ID ) ); ?>" class="regular-text" />
            </td>
        </tr>
       
        <tr>
            <th>
                <label for="code"><?php _e( 'Company Name' ); ?></label>
            </th>
            <td>
                <input type="text" name="company_name" id="company_name" value="<?php echo esc_attr( get_the_author_meta( 'company_name', $user->ID ) ); ?>" class="regular-text" />
            </td>
        </tr>
       
        <tr>
            <th>
                <label for="code"><?php _e( 'User Website' ); ?></label>
            </th>
            <td>
                <input type="text" name="user_website" id="user_website" value="<?php echo esc_attr( get_the_author_meta( 'user_website', $user->ID ) ); ?>" class="regular-text" />
            </td>
        </tr>
       
       
       
       
    </table>
<?php
}


// Hook is used to save custom fields that have been added to the WordPress profile page (if current user)
add_action( 'personal_options_update', 'update_extra_profile_fields' );

// Hook is used to save custom fields that have been added to the WordPress profile page (if not current user)
add_action( 'edit_user_profile_update', 'update_extra_profile_fields' );

function update_extra_profile_fields( $user_id ) {
    if ( current_user_can( 'edit_user', $user_id ) )
        update_user_meta( $user_id, 'user_app_store_link', $_POST['user_app_store_link'] );
        update_user_meta( $user_id, 'find_vertebrae', $_POST['find_vertebrae'] );
        update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
        update_user_meta( $user_id, 'user_website', $_POST['user_website'] );
   
}

Comments

Popular posts from this blog

add custom post type

/**  *  * add custom post type  *  */ function my_custom_post_product() {   $labels = array(     'name'               => _x( 'Products', 'post type general name' ),     'singular_name'      => _x( 'Product', 'post type singular name' ),     'add_new'            => _x( 'Add New', 'book' ),     'add_new_item'       => __( 'Add New Product' ),     'edit_item'          => __( 'Edit Product' ),     'new_item'           => __( 'New Product' ),     'all_items'          => __( 'All Products' ),     'vi...

Toolset conditional

[wpv- if evaluate= "'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']' OR '[wpv-current-user info='role']' = 'administrator'" ]      //the content you want to hide goes here [/wpv- if ]