Title: Dynamically Display HTML depending on User
Last modified: August 30, 2016

---

# Dynamically Display HTML depending on User

 *  Resolved [cameck](https://wordpress.org/support/users/cameck/)
 * (@cameck)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/)
 * Hi,
 * I’m trying to find a function I can hook into to.
 * I have two types of users on my BuddyPress site, employees and employers. These
   are defined in the user area of S2 Members.
 * I have made a custom profile page in my child theme labeled buddypress.php.
 * Everything is working fine, but I want to hide the make a payment button if the
   user’s profile is an employer profile.
 *     ```
       <?php if(is_user_logged_in() && 4 == S2MEMBER_CURRENT_USER_ACCESS_LEVEL){ ?>
   
       <div class="paybox">
       <h3>Make Payment with PayPal&reg;</h3>
       <?php $uemail = getDisplayedUserEmail(); ?>
       <?php echo do_shortcode('[gravityforms id="7" field_values="recip-email=' . $uemail . '"]'); ?>
       </div><!-- .paybox -->
   
       <?php } ?>
       ```
   
 * This is working for the most part, but oddly enough there are a few more employers
   that are still showing the paypal button. So, I started using this:
    `<?php echo
   S2MEMBER_CURRENT_USER_ACCESS_LEVEL; ?>` to see the output and most employers 
   are the number 2, but a few are listed as 4 – which creates the problem as the
   employEES asre listed as number 2 as well. Ideally, I could just do it like this`
   $type === $s2member_level1` as that’s how they are listed in the backend of WordPress,
   but that doesn’t work.
 * [https://wordpress.org/plugins/s2member/](https://wordpress.org/plugins/s2member/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [krumch](https://wordpress.org/support/users/krumch/)
 * (@krumch)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/#post-6788357)
 * Read Dashboard -> s2Member -> API / Scripting, there is shown [s2M conditions]
   and PHP functions, you will find what you need.
 *  Thread Starter [cameck](https://wordpress.org/support/users/cameck/)
 * (@cameck)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/#post-6788405)
 * Ok I think I’m realizing the problem here, all of theses codes are outputting
   the user access level of the person who is logged in, not the profile. I need
   to check the user access level of the user who’s profile is being viewed. All
   the code I am finding checks the user level of the logged in user. I haven’t 
   been able to find the code I’m looking for there. Do I make sense? I feel I might
   be being a little confusing
 *  [renzms](https://wordpress.org/support/users/renzms/)
 * (@renzms)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/#post-6788432)
 * You can take a look at WordPress Dashboard → s2Member → API / Scripting → s2Member
   PHP/API Constants
 * Also you can try reading the following :
 * [http://s2member.com/kb-article/s2get-shortcode-documentation/](http://s2member.com/kb-article/s2get-shortcode-documentation/)
   [https://www.s2member.com/codex/stable/s2member/api_functions/package-summary/](https://www.s2member.com/codex/stable/s2member/api_functions/package-summary/)
 * Checkout: Pulling Data for a Specific User and Pulling Data For Custom Registration/
   Profile Fields
 *  Thread Starter [cameck](https://wordpress.org/support/users/cameck/)
 * (@cameck)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/#post-6788446)
 * All right thank you everyone, I finally figured it out.
 * I was not able to find a function that worked for my specific task.
 * Luckily I had a custom BuddyPress field that also designated the user Level.
 * I got the field ID of “55” by hovering over the edit portion of the custom profile
   field.
 * This is the final working code:
 *     ```
       <?php if(is_user_logged_in() && xprofile_get_field_data( 55 ) == 'Employee'){ ?>
   
       <div class="paybox">
       <h3>Make Payment with PayPal&reg;</h3>
       <?php $uemail = getDisplayedUserEmail(); ?>
       <?php echo do_shortcode('[gravityforms id="7" field_values="recip-email=' . $uemail . '"]'); ?>
       </div><!-- .paybox -->
       <?php } ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Dynamically Display HTML depending on User’ is closed to new replies.

 * ![](https://ps.w.org/s2member/assets/icon-256x256.png?rev=980067)
 * [s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions](https://wordpress.org/plugins/s2member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/s2member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/s2member/)
 * [Active Topics](https://wordpress.org/support/plugin/s2member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/s2member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/s2member/reviews/)

## Tags

 * [users](https://wordpress.org/support/topic-tag/users/)

 * 4 replies
 * 3 participants
 * Last reply from: [cameck](https://wordpress.org/support/users/cameck/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/dynamically-display-html-depending-on-user/#post-6788446)
 * Status: resolved