Support

Account

Home Forums General Issues Show ACF field with link to ultimate member profile/WordPress user profile below

Unread

Show ACF field with link to ultimate member profile/WordPress user profile below

  • I’m trying to show a custom field below the single post. I managed to get the code to render below the post, but when I set the field movie_actors and save, the entire page goes blank after I refresh it, it doesn’t show any errors on the screen although I already have debug mode enabled.
    My field is set as User Object inside ACF, and the field type is user.
    What I’m trying to do is to show a link to the user profile in Ultimate Member. I also tried to show a link to the default wordpress user profile just in case, and it also gives me the same result.

    I’m doing this inside my custom functions plugin (equivalent to functions.php).

    I’m going to be leaving both codes here just in case:

    This one is for Ultimate Member plugin:

        function wpb_after_post_content($content){ if (is_single()) { 
        global $post;
        
        $content .= '<p>CAST</p>' .
        
        '<div id="meta-coauthor"><span class="metacoauteur">' .
        
        		$values = get_field('movie_actors', $post->ID); 
        		if($values) { 
        			foreach($values as $value)	{
        				$author_ID = $value['ID'];
                                        um_fetch_user( $author_ID) . '<a href="'.um_user_profile_url( ).'">' . um_user("display_name") . '</a>';
        			}	
        		}; 
        	'	</span>
        </div>';
        
         }
            return $content;
        }
        add_filter( "the_content", "wpb_after_post_content", 9999 );
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 100, 50, true );

    And this one is for the default WordPress user profile:

        function wpb_after_post_content($content){ if (is_single()) { 
        global $post;
        
        $content .= '<p>CAST</p>' .
        
         '<div id="meta-coauthor"><span class="metacoauteur">' .
        
        		$values = get_field('movie_actors', $post->ID); 
        		if($values) { 
        			foreach($values as $value)	{
        				$author_ID = $value['ID'];
        				$author_url = esc_url( get_author_posts_url($author_ID) ) . ' <a href="'.$author_url.'">' . $value['display_name'] . '</a>';
        			  
        			}	
        		}; 
        	'	</span>
        </div>';
        
        
         }
            return $content;
        }
        add_filter( "the_content", "wpb_after_post_content", 9999 );
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 100, 50, true );
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.