Skip to:
Content
Pages
Categories
Search
Top
Bottom

Bps_display shortcode

  • @bennyhoang

    Participant

    Hey!
    I am currently trying to get specific field_names from a field ID with shortcode. Is this possible?

    [bps_display form=593]

    I am wondering if i could do something like:
    [bps_display form=593 field_name=”username”]

Viewing 1 replies (of 1 total)
  • @william_oneb

    Participant

    @bennyhoang

    Paste this code in your theme’s functions.php

    function bennyhoang ($atts) {
             // Start by checking if the user if logged in
              if ( is_user_logged_in() ) {
             // Let's grab the user id
             $user_id = bp_loggedin_user_id();
             // Let's find a field called name. (REPLACE "NAME" WITH THE NAME OF THE FIELD YOU WANT)
             $Name = xprofile_get_field_data( 'Name' ,$user_id);
             // Let's output that field
             return $Name;
       } 
    }
    
    add_shortcode( 'benny', 'bennyhoang' ); 

    [benny] is your shortcode! Use it your pages/posts!

Viewing 1 replies (of 1 total)
  • The topic ‘Bps_display shortcode’ is closed to new replies.
Skip to toolbar