• Hi,
    I’ve been trying to edit the profile.php page, but I cannot get it to show any of the acf custom fields if I’m not editing my profile.

    I want people to be able to see all the details, but if I’m not logged in then nothing is displayed.

    <?php if ( ! defined( 'ABSPATH' ) ) exit;
    /* Template: FSA Profile Page */
    ?>
    
    <div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?> um-role-<?php echo esc_attr( um_user( 'role' ) ); ?> ">
    
    	<div class="um-form" data-mode="<?php echo esc_attr( $mode ) ?>">
    
    		<?php
    
    		/**
    
    		 * UM hook
    
    		 *
    
    		 * @type action
    
    		 * @title um_profile_before_header
    
    		 * @description Some actions before profile form header
    
    		 * @input_vars
    
    		 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    		 * @change_log
    
    		 * ["Since: 2.0"]
    
    		 * @usage add_action( 'um_profile_before_header', 'function_name', 10, 1 );
    
    		 * @example
    
    		 * <?php
    
    		 * add_action( 'um_profile_before_header', 'my_profile_before_header', 10, 1 );
    
    		 * function my_profile_before_header( $args ) {
    
    		 *     // your code here
    
    		 * }
    
    		 * ?>
    
    		 */
    
    		do_action( 'um_profile_before_header', $args );
    
    		if ( um_is_on_edit_profile() ) { ?>
    
    			<form method="post" action="">
    
    		<?php }
    
    		/**
    
    		 * UM hook
    
    		 *
    
    		 * @type action
    
    		 * @title um_profile_header_cover_area
    
    		 * @description Profile header cover area
    
    		 * @input_vars
    
    		 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    		 * @change_log
    
    		 * ["Since: 2.0"]
    
    		 * @usage add_action( 'um_profile_header_cover_area', 'function_name', 10, 1 );
    
    		 * @example
    
    		 * <?php
    
    		 * add_action( 'um_profile_header_cover_area', 'my_profile_header_cover_area', 10, 1 );
    
    		 * function my_profile_header_cover_area( $args ) {
    
    		 *     // your code here
    
    		 * }
    
    		 * ?>
    
    		 */
    
    		do_action( 'um_profile_header_cover_area', $args );
    
    		/**
    
    		 * UM hook
    
    		 *
    
    		 * @type action
    
    		 * @title um_profile_header
    
    		 * @description Profile header area
    
    		 * @input_vars
    
    		 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    		 * @change_log
    
    		 * ["Since: 2.0"]
    
    		 * @usage add_action( 'um_profile_header', 'function_name', 10, 1 );
    
    		 * @example
    
    		 * <?php
    
    		 * add_action( 'um_profile_header', 'my_profile_header', 10, 1 );
    
    		 * function my_profile_header( $args ) {
    
    		 *     // your code here
    
    		 * }
    
    		 * ?>
    
    		 */
    
    		do_action( 'um_profile_header', $args );
    
    		/**
    
    		 * UM hook
    
    		 *
    
    		 * @type filter
    
    		 * @title um_profile_navbar_classes
    
    		 * @description Additional classes for profile navbar
    
    		 * @input_vars
    
    		 * [{"var":"$classes","type":"string","desc":"UM Posts Tab query"}]
    
    		 * @change_log
    
    		 * ["Since: 2.0"]
    
    		 * @usage
    
    		 * <?php add_filter( 'um_profile_navbar_classes', 'function_name', 10, 1 ); ?>
    
    		 * @example
    
    		 * <?php
    
    		 * add_filter( 'um_profile_navbar_classes', 'my_profile_navbar_classes', 10, 1 );
    
    		 * function my_profile_navbar_classes( $classes ) {
    
    		 *     // your code here
    
    		 *     return $classes;
    
    		 * }
    
    		 * ?>
    
    		 */
    
    		$classes = apply_filters( 'um_profile_navbar_classes', '' ); ?>
    
    		<div class="um-profile-navbar <?php echo esc_attr( $classes ); ?>">
    
    			<?php
    
    			/**
    
    			 * UM hook
    
    			 *
    
    			 * @type action
    
    			 * @title um_profile_navbar
    
    			 * @description Profile navigation bar
    
    			 * @input_vars
    
    			 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    			 * @change_log
    
    			 * ["Since: 2.0"]
    
    			 * @usage add_action( 'um_profile_navbar', 'function_name', 10, 1 );
    
    			 * @example
    
    			 * <?php
    
    			 * add_action( 'um_profile_navbar', 'my_profile_navbar', 10, 1 );
    
    			 * function my_profile_navbar( $args ) {
    
    			 *     // your code here
    
    			 * }
    
    			 * ?>
    
    			 */
    
    			do_action( 'um_profile_navbar', $args ); ?>
    
    			<div class="um-clear"></div>
    
    		</div>
    
    		<?php
    
    		/**
    
    		 * UM hook
    
    		 *
    
    		 * @type action
    
    		 * @title um_profile_menu
    
    		 * @description Profile menu
    
    		 * @input_vars
    
    		 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    		 * @change_log
    
    		 * ["Since: 2.0"]
    
    		 * @usage add_action( 'um_profile_menu', 'function_name', 10, 1 );
    
    		 * @example
    
    		 * <?php
    
    		 * add_action( 'um_profile_menu', 'my_profile_navbar', 10, 1 );
    
    		 * function my_profile_navbar( $args ) {
    
    		 *     // your code here
    
    		 * }
    
    		 * ?>
    
    		 */
    
    		do_action( 'um_profile_menu', $args );
    
    		if ( um_is_on_edit_profile() || UM()->user()->preview ) {
    
    			$nav = 'main';
    
    			$subnav = UM()->profile()->active_subnav();
    
    			$subnav = ! empty( $subnav ) ? $subnav : 'default'; ?>
    
    			<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    
    				<?php
    
    				/**
    
    				 * UM hook
    
    				 *
    
    				 * @type action
    
    				 * @title um_profile_content_{$nav}
    
    				 * @description Custom hook to display tabbed content
    
    				 * @input_vars
    
    				 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    				 * @change_log
    
    				 * ["Since: 2.0"]
    
    				 * @usage add_action( 'um_profile_content_{$nav}', 'function_name', 10, 1 );
    
    				 * @example
    
    				 * <?php
    
    				 * add_action( 'um_profile_content_{$nav}', 'my_profile_content', 10, 1 );
    
    				 * function my_profile_content( $args ) {
    
    				 *     // your code here
    
    				 * }
    
    				 * ?>
    
    				 */
    
    				do_action("um_profile_content_{$nav}", $args);
    
    				/**
    
    				 * UM hook
    
    				 *
    
    				 * @type action
    
    				 * @title um_profile_content_{$nav}_{$subnav}
    
    				 * @description Custom hook to display tabbed content
    
    				 * @input_vars
    
    				 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    				 * @change_log
    
    				 * ["Since: 2.0"]
    
    				 * @usage add_action( 'um_profile_content_{$nav}_{$subnav}', 'function_name', 10, 1 );
    
    				 * @example
    
    				 * <?php
    
    				 * add_action( 'um_profile_content_{$nav}_{$subnav}', 'my_profile_content', 10, 1 );
    
    				 * function my_profile_content( $args ) {
    
    				 *     // your code here
    
    				 * }
    
    				 * ?>
    
    				 */
    
    				do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    
    				<div class="clear"></div>
    
    			</div>
    
    			<?php if ( ! UM()->user()->preview ) { ?>
    
    			</form>
    
    			<?php }
    			
    		} else {
    
    			$menu_enabled = UM()->options()->get( 'profile_menu' );
    
    			$tabs = UM()->profile()->tabs_active();
    
    			$nav = UM()->profile()->active_tab();
    
    			$subnav = UM()->profile()->active_subnav();
    
    			$subnav = ! empty( $subnav ) ? $subnav : 'default';
    
    			if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?>
    
    				<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    
    					<?php
    
    					// Custom hook to display tabbed content
    
    					/**
    
    					 * UM hook
    
    					 *
    
    					 * @type action
    
    					 * @title um_profile_content_{$nav}
    
    					 * @description Custom hook to display tabbed content
    
    					 * @input_vars
    
    					 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    					 * @change_log
    
    					 * ["Since: 2.0"]
    
    					 * @usage add_action( 'um_profile_content_{$nav}', 'function_name', 10, 1 );
    
    					 * @example
    
    					 * <?php
    
    					 * add_action( 'um_profile_content_{$nav}', 'my_profile_content', 10, 1 );
    
    					 * function my_profile_content( $args ) {
    
    					 *     // your code here
    
    					 * }
    
    					 * ?>
    
    					 */
    
    					do_action("um_profile_content_{$nav}", $args);
    
    					/**
    
    					 * UM hook
    
    					 *
    
    					 * @type action
    
    					 * @title um_profile_content_{$nav}_{$subnav}
    
    					 * @description Custom hook to display tabbed content
    
    					 * @input_vars
    
    					 * [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
    
    					 * @change_log
    
    					 * ["Since: 2.0"]
    
    					 * @usage add_action( 'um_profile_content_{$nav}_{$subnav}', 'function_name', 10, 1 );
    
    					 * @example
    
    					 * <?php
    
    					 * add_action( 'um_profile_content_{$nav}_{$subnav}', 'my_profile_content', 10, 1 );
    
    					 * function my_profile_content( $args ) {
    
    					 *     // your code here
    
    					 * }
    
    					 * ?>
    
    					 */
    
    					do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    
    					<div class="clear"></div>
    
    				</div>
    
    			<?php }
    
    		}
    ?>
    
    <div>
    <?php echo do_shortcode("[acf field='company_email']"); ?>
    so is this just text
    <p><?php the_field('company_email'); ?></p>
    <?php
    		do_action( 'um_profile_footer', $args ); ?>
    
    	</div>
    
    </div>

    Thats the current page code – I can see the text “so is this just text” on the page but none of the fields display.

    Can anyone help please?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @tridentmarketing

    I believe you will also have to pass the user id. If you are just trying to show company email where “so is this just text” text is, you can just following code snippet:

    add_action( 'um_profile_footer', function( $args ){
    	$profile_id = um_profile_id();
    	$company_email = get_field('author_badge', 'user_'. $profile_id );
    	echo $company_email;
    });

    Regards,

    Thread Starter Trident Marketing Anglia Ltd

    (@tridentmarketing)

    Hi there,

    I added your code and by changing the field names etc I managed to get it working.
    I’ve stripped out a lot of the code as I simply want a page that looks to see if I’m editing the page or not – if im not then display the profile, if I am then display the form.

    My current code is:

    <?php if ( ! defined( 'ABSPATH' ) ) exit;
    /* Template: FSA Profile Page */
    ?>
    
    <div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?> um-role-<?php echo esc_attr( um_user( 'role' ) ); ?> ">
    
    	<div class="um-form" data-mode="<?php echo esc_attr( $mode ) ?>">
    
    		<?php
    		do_action( 'um_profile_before_header', $args );
    		if ( um_is_on_edit_profile() ) { ?>
    			<form method="post" action="">
    		<?php }
    		do_action( 'um_profile_header_cover_area', $args );
    		do_action( 'um_profile_header', $args );
    
    		 $classes = apply_filters( 'um_profile_navbar_classes', '' ); ?>
    
    	<div class="um-profile-navbar <?php echo esc_attr( $classes ); ?>">
    		<?php
    		do_action( 'um_profile_navbar', $args ); ?>
    			<div class="um-clear"></div>
    	</div>
    		<?php
    		do_action( 'um_profile_menu', $args );
    
    		if ( um_is_on_edit_profile() || UM()->user()->preview ) {
    
    			$nav = 'main';
    			$subnav = UM()->profile()->active_subnav();
    			$subnav = ! empty( $subnav ) ? $subnav : 'default'; ?>
    
    			<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    
    		<?php
    				do_action("um_profile_content_{$nav}", $args);
    				do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    				<div class="clear"></div>
    			</div>
    
    		<?php if ( ! UM()->user()->preview ) { ?>
    
    		</form>
    
    		<?php }
    			
    		} else {
    
    			$menu_enabled = UM()->options()->get( 'profile_menu' );
    			$tabs = UM()->profile()->tabs_active();
    			$nav = UM()->profile()->active_tab();
    			$subnav = UM()->profile()->active_subnav();
    			$subnav = ! empty( $subnav ) ? $subnav : 'default';
    			if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?>
    
    			<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    		<?php
    				do_action("um_profile_content_{$nav}", $args);
    				do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    			<div class="clear"></div>
    			</div>
    
    		<?php }
    		}
    ?>
    
    <div>
    <?
    //	if ( um_is_on_edit_profile() ) { } else {
    	
    add_action( 'um_profile_footer', function( $args ){
    	$profile_id = um_profile_id();
    	$company_name = get_field('company_name', 'user_'. $profile_id );
    	$company_details = get_field('company_details', 'user_'. $profile_id );
    	$company_phone = get_field('company_phone', 'user_'. $profile_id );
    	$company_email = get_field('company_email', 'user_'. $profile_id );
    	$company_website = get_field('company_website', 'user_'. $profile_id );
    	$company_address = get_field('company_address', 'user_'. $profile_id );
    	$company_postcode = get_field('company_postcode', 'user_'. $profile_id );
    	$company_category = get_field('company_category', 'user_'. $profile_id );
    	$company_logo = get_avatar( $profile_id, 32 );
    });
    ?>
    
    	<div class="um-header no-cover">
    		<div class="um-profile-photo" data-user_id="<?php echo $profile_id; ?>">
    			<img src="<?php echo $company_logo; ?>" class="gravatar avatar avatar-190 um-avatar um-avatar-uploaded" width="190" height="190" alt="<?php echo $company_name; ?>" />
    		</div>
    		<div class="um-profile-meta">
    			<div class="um-main-meta">				
    				<div class="um-clear"></div>
    			</div>
    			<div class="um-meta">
    				<span><p><?php echo $company_details; ?></p></span>
    			</div>		
    		</div>
    		<div class="um-clear"></div>
    	</div>
    
    	<div class="um-profile-body main main-default">
    
    				<div class="um-row _um_row_1 " style="margin: 0 0 30px 0;">
    					<div class="um-col-121">
    						<div  id="um_field" class="um-field">Address</div>
    						<div class="um-field-area"><?php echo $company_address; ?></div>
    						<div  id="um_field" class="um-field">Postcode</div>
    						<div class="um-field-area"><?php echo $company_postcode; ?></div>
    					</div>
    					<div class="um-col-122">
    						<div  id="um_field" class="um-field ">Phone</div>
    						<div class="um-field-area"><a href="tel:<?php echo $company_phone; ?>"><?php echo $company_phone; ?></a></div>
    						<div  id="um_field" class="um-field">Email</div>
    						<div class="um-field-area"><a href="mailto:<?php echo $company_email; ?>"><?php echo $company_email; ?></a></div>
    						<div  id="um_field" class="um-field">Website</div>
    						<div class="um-field-area"><a href="<?php echo $company_website; ?>"><?php echo $company_website; ?></a></div>
    						<div  id="um_field" class="um-field">Category</div>
    						<div class="um-field-area"><?php echo $company_category; ?></div>
    					</div>
    				</div>
    	</div>
    </div>
    
    <?php
    	//	}
    		do_action( 'um_profile_footer', $args ); ?>
    
    	</div>
    
    </div>

    However its now broken and not displaying the fields.
    Any ideas?

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @tridentmarketing

    Sorry for the late response. Those variables added to the um_profile_footer are not declared outside the function that’s why it’s throwing an error when you added them to display in the HTML above the do_action("um_profile_footer").

    You can try the following with our changes:

    <?php if ( ! defined( 'ABSPATH' ) ) exit;
    /* Template: FSA Profile Page */
    ?>
    
    <div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?> um-role-<?php echo esc_attr( um_user( 'role' ) ); ?> ">
    
    	<div class="um-form" data-mode="<?php echo esc_attr( $mode ) ?>">
    
    		<?php
    		do_action( 'um_profile_before_header', $args );
    		if ( um_is_on_edit_profile() ) { ?>
    			<form method="post" action="">
    		<?php }
    		do_action( 'um_profile_header_cover_area', $args );
    		do_action( 'um_profile_header', $args );
    
    		 $classes = apply_filters( 'um_profile_navbar_classes', '' ); ?>
    
    	<div class="um-profile-navbar <?php echo esc_attr( $classes ); ?>">
    		<?php
    		do_action( 'um_profile_navbar', $args ); ?>
    			<div class="um-clear"></div>
    	</div>
    		<?php
    		do_action( 'um_profile_menu', $args );
    
    		if ( um_is_on_edit_profile() || UM()->user()->preview ) {
    
    			$nav = 'main';
    			$subnav = UM()->profile()->active_subnav();
    			$subnav = ! empty( $subnav ) ? $subnav : 'default'; ?>
    
    			<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    
    		<?php
    				do_action("um_profile_content_{$nav}", $args);
    				do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    				<div class="clear"></div>
    			</div>
    
    		<?php if ( ! UM()->user()->preview ) { ?>
    
    		</form>
    
    		<?php }
    			
    		} else {
    
    			$menu_enabled = UM()->options()->get( 'profile_menu' );
    			$tabs = UM()->profile()->tabs_active();
    			$nav = UM()->profile()->active_tab();
    			$subnav = UM()->profile()->active_subnav();
    			$subnav = ! empty( $subnav ) ? $subnav : 'default';
    			if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?>
    
    			<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
    		<?php
    				do_action("um_profile_content_{$nav}", $args);
    				do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
    			<div class="clear"></div>
    			</div>
    
    		<?php }
    		}
    ?>
    
    <div>
    <?
    //	if ( um_is_on_edit_profile() ) { } else {
    	
            $company_name = "";
    	$company_details= "";
    	$company_phone = "";
    	$company_email = "";
    	$company_website = "";
    	$company_address = "";
    	$company_postcode = "";
    	$company_category = "";
    	$company_logo = "";
    
    add_action( 'um_profile_footer', function( $args ){
    	$profile_id = um_profile_id();
    	$company_name = get_field('company_name', 'user_'. $profile_id );
    	$company_details = get_field('company_details', 'user_'. $profile_id );
    	$company_phone = get_field('company_phone', 'user_'. $profile_id );
    	$company_email = get_field('company_email', 'user_'. $profile_id );
    	$company_website = get_field('company_website', 'user_'. $profile_id );
    	$company_address = get_field('company_address', 'user_'. $profile_id );
    	$company_postcode = get_field('company_postcode', 'user_'. $profile_id );
    	$company_category = get_field('company_category', 'user_'. $profile_id );
    	$company_logo = get_avatar( $profile_id, 32 );
    });
    ?>
    
    	<div class="um-header no-cover">
    		<div class="um-profile-photo" data-user_id="<?php echo $profile_id; ?>">
    			<img src="<?php echo $company_logo; ?>" class="gravatar avatar avatar-190 um-avatar um-avatar-uploaded" width="190" height="190" alt="<?php echo $company_name; ?>" />
    		</div>
    		<div class="um-profile-meta">
    			<div class="um-main-meta">				
    				<div class="um-clear"></div>
    			</div>
    			<div class="um-meta">
    				<span><p><?php echo $company_details; ?></p></span>
    			</div>		
    		</div>
    		<div class="um-clear"></div>
    	</div>
    
    	<div class="um-profile-body main main-default">
    
    				<div class="um-row _um_row_1 " style="margin: 0 0 30px 0;">
    					<div class="um-col-121">
    						<div  id="um_field" class="um-field">Address</div>
    						<div class="um-field-area"><?php echo $company_address; ?></div>
    						<div  id="um_field" class="um-field">Postcode</div>
    						<div class="um-field-area"><?php echo $company_postcode; ?></div>
    					</div>
    					<div class="um-col-122">
    						<div  id="um_field" class="um-field ">Phone</div>
    						<div class="um-field-area"><a href="tel:<?php echo $company_phone; ?>"><?php echo $company_phone; ?></a></div>
    						<div  id="um_field" class="um-field">Email</div>
    						<div class="um-field-area"><a href="mailto:<?php echo $company_email; ?>"><?php echo $company_email; ?></a></div>
    						<div  id="um_field" class="um-field">Website</div>
    						<div class="um-field-area"><a href="<?php echo $company_website; ?>"><?php echo $company_website; ?></a></div>
    						<div  id="um_field" class="um-field">Category</div>
    						<div class="um-field-area"><?php echo $company_category; ?></div>
    					</div>
    				</div>
    	</div>
    </div>
    
    <?php
    	//	}
    		do_action( 'um_profile_footer', $args ); ?>
    
    	</div>
    
    </div>
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘cannot see any acf form fields on my profile page’ is closed to new replies.