Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //User profile custom field for extra information (Backend in Dashboard user profile)
- // user profile custom field
- add_action('show_user_profile', 'yoursite_extra_user_profile_fields');
- add_action('edit_user_profile', 'yoursite_extra_user_profile_fields');
- function yoursite_extra_user_profile_fields($user)
- {
- ?>
- <h3><?php _e("Extra profile information", "blank"); ?></h3>
- <table class="form-table">
- <tr>
- <th><label for="designation"><?php _e("Designation"); ?></label></th>
- <td>
- <input type="text" name="designation" id="designation" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('designation', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your designation."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="facebook_p_link"><?php _e("Facebook Profile Link"); ?></label></th>
- <td>
- <input type="text" name="facebook_p_link" id="facebook_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('facebook_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your Facebook Link."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="twitter_p_link"><?php _e("Twitter Profile Link"); ?></label></th>
- <td>
- <input type="text" name="twitter_p_link" id="twitter_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('twitter_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your Twitter Link."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="linkedin_p_link"><?php _e("Linkedin Profile Link"); ?></label></th>
- <td>
- <input type="text" name="linkedin_p_link" id="linkedin_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('linkedin_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your Twitter Link."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="pinterest_p_link"><?php _e("Pintrest Profile Link"); ?></label></th>
- <td>
- <input type="text" name="pinterest_p_link" id="pinterest_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('pinterest_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your Pinterest Link."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="gplus_p_link"><?php _e("Google Plus Profile Link"); ?></label></th>
- <td>
- <input type="text" name="gplus_p_link" id="gplus_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('gplus_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your Google Plus Link."); ?></span>
- </td>
- </tr>
- <tr>
- <th><label for="vk_p_link"><?php _e("VK Profile Link"); ?></label></th>
- <td>
- <input type="text" name="vk_p_link" id="vk_p_link" class="regular-text"
- value="<?php echo esc_attr(get_the_author_meta('vk_p_link', $user->ID)); ?>"/><br/>
- <span class="description"><?php _e("Enter your VK Link."); ?></span>
- </td>
- </tr>
- </table>
- <?php
- }
- // user profile data save
- add_action('personal_options_update', 'yoursite_save_extra_user_profile_fields');
- add_action('edit_user_profile_update', 'yoursite_save_extra_user_profile_fields');
- function yoursite_save_extra_user_profile_fields($user_id)
- {
- $saved = false;
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'designation', $_POST['designation']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'facebook_p_link', $_POST['facebook_p_link']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'twitter_p_link', $_POST['twitter_p_link']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'linkedin_p_link', $_POST['linkedin_p_link']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'pinterest_p_link', $_POST['pinterest_p_link']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'gplus_p_link', $_POST['gplus_p_link']);
- $saved = true;
- }
- if (current_user_can('edit_user', $user_id)) {
- update_user_meta($user_id, 'vk_p_link', $_POST['vk_p_link']);
- $saved = true;
- }
- return true;
- }
- //Display result in Front-end
- <div class="ic-author-info media">
- <?php echo get_avatar(get_the_author_meta()); ?>
- <div class="media-body">
- <h4><?php echo get_the_author(); ?></h4>
- <span><?php echo esc_attr(get_the_author_meta('designation', $user_ID)); ?></span>
- <p><?php echo get_the_author_meta('description'); ?></p>
- <div class="ic-social">
- <ul>
- <?php if (!empty(get_the_author_meta('facebook_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('facebook_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-facebook"></i>
- </a>
- </li>
- <?php endif; ?>
- <?php if (!empty(get_the_author_meta('twitter_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('twitter_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-facebook"></i>
- </a>
- </li>
- <?php endif; ?>
- <?php if (!empty(get_the_author_meta('linkedin_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('linkedin_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-linkedin"></i>
- </a>
- </li>
- <?php endif; ?>
- <?php if (!empty(get_the_author_meta('pinterest_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('pinterest_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-pinterest"></i>
- </a>
- </li>
- <?php endif; ?>
- <?php if (!empty(get_the_author_meta('gplus_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('gplus_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-google-plus"></i>
- </a>
- </li>
- <?php endif; ?>
- <?php if (!empty(get_the_author_meta('vk_p_link', $user->ID))) : ?>
- <li>
- <a href="<?php echo esc_url(get_the_author_meta('vk_p_link', $user->ID)); ?>">
- <i class="icofont icofont-social-social-vk"></i>
- </a>
- </li>
- <?php endif; ?>
- </ul>
- </div>
- <div class="ic-navigation">
- <ul>
- <?php previous_post_link('<li class="float-left nav-prev">%link</li>', '<span><i class="icofont icofont-long-arrow-left"></i></span> Previous'); ?>
- <?php next_post_link('<li class="float-right nav-next">%link</li>', 'Next <span><i class="icofont icofont-long-arrow-right"></i></span>'); ?>
- </ul>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement