UserPro Forums
  • Create new topic
  • Forums
    • No replies topics
    • Newest topics
    • Forum statistics
  • Account
    • Lost password
    • Register
    • Login
  • Documentation
  • Back to main site

Community Forums

User To User Support Forum/Forums/Support Questions (UserPro)/Shortcodes for custom fields

Shortcodes for custom fields

  • 8 years, 6 months ago AvatarNexnivis
    Participant

    Hi there !

    I love the conditionnal shortcode [profile_by_url], it’s a really great tool ! But I think we could make it more incredible by adding ability to display custom fields into it !

    Currently we just can put [username], [role] etc…, but what about shortcodes for custom fields ? For example [field=”mycustomfield”], like this we can show the value of a custom field of the profile we are viewing !

    I hope I’m understandable, sorry for my bad english !

    Regards

    8 years, 6 months ago Avatartest
    Participant

    This is already possible, unless I’m missing something.
    [userpro template=view] <–default profile by url view…
    [userpro template=view yourcustomkey="customvalue"] <–still using default by URL with your added key/value…

    8 years, 6 months ago AvatarRonnie Trainham
    Participant

    Ooops.. I forgot to login to my account. Well atleast the test account has been tested..

    8 years, 6 months ago AvatarNexnivis
    Participant

    Thanks Ronnie but it’s not what I’m looking for !

    For example if I make this : [profile_by_url]Your are on the profile of [username], his role is [role][/profile_by_url] under the profile view. If I come on your profile I’ll obtain the sentence “You are on the profile of Ronnie, his role is subscriber”.

    Now I want to put some custom fields into this. For example if I have a custom field “Town”, I want to make something like [profile_by_url]Your are on the profile of [username], his role is [role] and he live in [town][/profile_by_url]

    8 years, 6 months ago AvatarRonnie Trainham
    Participant

    Ahh, I see now..

    You could always put something like this in your functions.php file.

    NOTE:This is untested and will require a little more tweaking to get the output desired.
    function custom_userpro_sc( $atts ) {

    extract( shortcode_atts(
    array(
    ‘user_id’ => ”,
    ), $atts )
    );

    if ( isset( $user_id ) ) {

    echo userpro_profile_data(‘custom_field_1’, $user_id);
    }
    add_shortcode( ‘cf_1’, ‘custom_userpro_sc’ );

    Then you could use the [cf_1 user_id=””] shortcode once you pass the $user_id as an attribute, possibly using a global var.

    8 years, 6 months ago Avataradmin
    Keymaster

    @Nexnivis – Check this – http://userproplugin.com/userpro/forums/topic/show-personalized-profile-data/

    Is it the same thing you are looking for?

    8 years, 6 months ago AvatarNexnivis
    Participant

    Hi Ahmed.

    Yes I’m talking about these conditionnals shortcode, but I already use it since few months. I want to use custom fields with these shortcodes.

    Currently we just can put some pre-defined fields into it (like [username], [role], etc…) but it would be amazing if we could show custom fields too.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Disclaimer

This forum is 100% free and USER to USER support only. Technical support staff doesn’t monitor this forum actively.

If you are a customer and want to get technical support from our staff please submit a technical support ticket here: UserPRO Technical Support

Recent Topics

  • Custom Badges AddOn Plugin here
  • Green Trust Cash APplication
  • How to use cash app without a bank account
  • Install Cash App on your Device [100%] by yourself | Step-by-Step Guide
  • Green Trust Cash Application

About forum

Here you can find help from UserPro plugin developers and other UserPro fellow users. Please be polite and ask your questions. NO SPAM!

Search Forums

Follow us

  • facebook
  • twitter
  • youtube
© Copyright UserPro