Tagged: shortcode xProfile
Hi Peter,
Welcome to BuddyDev.This is doable if you want your users to enter some data. In case of BuddyPress, only a field with some data is fetched and shown on profile page.
If you want to create a field which uses shortcode from another plugin but the user does not enter any data, It is not doable(atleast easily since BuddyPress won’t list the field).
If you want, You can provide me a field id(text or multiline text field) and I can help getting your shortcode working in it.
Regards
BrajeshBasically, it should be such that only the admin can fill this field.
I used e.g. the Football Leagues plugin.
Here there is a short code of clubs or tables.
I would like to display this club or table in the user profile page.
The shortcode looks like this:
[anwpfl-clubs competition_id = "" logo_size = "big" logo_height = "50px" logo_width = "50px" exclude_ids = ""]
Now I have created a field with the name: Club.
Title: Club
Type: Text area
Meta name: user_vereinIf I now enter the shortcode, I will not see the club but only the shortcode.
HI Peter,
Here is an exampleadd_filter( 'xprofile_get_field_data', function ( $value, $field_id, $user_id ) { if ( 5 != $field_id || is_array( $value ) ) { return $value; } return do_shortcode( $value ); }, 10, 3 );
Please add it to your bp-custom.php and try.
Regards
BrajeshHEllo,
i canĀ“t find a file with the name: bp-custom.php
Regrads
UPDATE:
I created the file and then uploaded it to the wp-content / plugins folder
– ` <?php
// hacks and mods will go here
add_filter( ‘xprofile_get_field_data’, function ( $value, $field_id, $user_id ) {if ( 3 != $field_id || is_array( $value ) ) {
return $value;
}return do_shortcode( $value );
}, 10, 3 );
?> `.But the shortcode is not displayed.
The field remains empty- This reply was modified 5 years ago by
Peter.
- This reply was modified 5 years ago by
Hi Peter,
Thank you for confirming.Yes, It will work for one line text fields too.
Regards
Brajesh
The topic ‘Display a shortcode in Xprofile fields from another Plugin.’ is closed to new replies.