New Check out the curated list of the finest design resources I've gathered for you! Take a look →

How to Create Custom User Profiles with WordPress ACF

Are you interested in improving your WordPress website by allowing users to add their social media accounts to their profiles? you can easily create custom user profiles with wordpress ACF.

In this tutorial, I will guide you on how to create custom user profiles with WordPress ACF and add social media accounts to them.

Step 1. Creating a Field Group in ACF

To add custom fields to the user profile page, the first step is to register a new field group in ACF. Go to the ACF plugin and create a new field group. Add the necessary fields, such as Name and URL accounts, and put them inside the repeater-field.

Register a new field group for create custom user profiles with WordPress ACF
Register a new field group to create custom user profiles with WordPress ACF
Set the rules for showing custom fields
Set the rules for showing custom fields

To ensure that the subscriber user role is not able to edit the content, set the permissions accordingly. Once you have created the field group, it will be displayed on the user profile page.

Step 2. Showcasing the Custom Field in a Single Post

 Displayed on the user profile page
Displayed on the user profile page

To display the custom field in a single post, you need to add the necessary code to your theme.

In this example, I will use the twenty-twenty one theme

First, add the code to the template-tags.php file for the twenty_twenty_one_posted_by() function to show the content to the user profile page. You can add this code to your theme using the WordPress child theme. Then, the social media accounts will be displayed on the single post page.

function twenty_twenty_one_posted_by() {
  if ( ! get_the_author_meta( 'description' ) && post_type_supports( get_post_type(), 'author' ) ) {
    echo '<span class="byline">';
    printf(
      /* translators: %s: Author name. */
      esc_html__( 'By %s', 'twentytwentyone' ),
      '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a>'
    );
    echo '</span>';

    $author_id = get_the_author_meta( 'ID' );
    if ( have_rows( 'socials', 'user_' . $author_id ) ) :
      echo '<ul style="padding-left: 1rem; display: inline-flex; gap: 2.5rem;">';
      while ( have_rows( 'socials', 'user_' . $author_id) ) : the_row();
        echo '<li><a href='. get_sub_field('url') .'>'. get_sub_field('label') .'</a></li>';
      endwhile;
      echo '</ul>';
    endif;
  }
}
Fill the socials media accounts fields
Fill the socials media accounts fields

If all goes well, you should see the custom social media links in the single post as registered in Step 1.

Displayed on the single post page
Displayed on the single post page

By following these simple steps, you have successfully created custom user profiles with WordPress ACF. For more ACF tutorials, check out this link or browse our case studies.

Building WordPress Website can be a challenging task, especially when you want to add custom features. However, with ACF, creating custom user profiles with WordPress ACF is a breeze. By following the steps outlined in this tutorial, you can add social media accounts to your user profiles and enhance your WordPress website’s functionality.

For more ACF tutorials, check out this link or browse our case studies.

Rizwan Aritonang

An independent WordPress & Front-End Developer from Bandung, Indonesia.

Get In Touch

Leave a Comment