Plugin Author
Stiofan
(@stiofansisland)
Hi @gxwpm,
I am not exactly sure what you mean, can you explain a bit more or give examples?
Thanks,
Stiofan
Thread Starter
gxwpm
(@gxwpm)
Sure,
I have a shortcode for myCRED that shows a point balance of my currently logged in user.
Shortcode is [mycred_my_balance] and it returns a value like “24 Pts” when it is used.
What I want is to create a field named “Points” that will show this shortcode returned value on my UsersWP profile (Points: 24 Pts). It shouldn’t be modified by user via Account page and must be ready-only.
I’ve tried to put it as a default value of a field but what I saw was “Points: [mycred_my_balance]”.
Plugin Author
Stiofan
(@stiofansisland)
We don’t have a shortcode that does that, but we could give you a PHP snippet?
We have a myCRED https://userswp.io/downloads/mycred/ addon that will show users points and also allow them to get points for things and even transfer points to each other.
Thanks,
Stiofan
Thread Starter
gxwpm
(@gxwpm)
Yeah, I’ve noticed that addon thinking to buy it after I completed implement a profile management to my website. Still trying to configure and modify UsersWP.
And about snippet, any way that would help me to show some out of form data on UsersWP fields, would be ok for me. Sorry if I can’t describe well.
There are some shortcodes as I mentioned, not myCRED specific, any shortcode from any plugin. One for example, returns user’s ID with something like [user-id]. All I try to do is, use this shortcodes inside my UsersWP fields.
I’ll create a field that named User ID and it’ll be admin managed field. I want to use it’s default value with a shortcode so that user may see it on his More Info tab as User ID: 23 etc.
Plugin Author
Stiofan
(@stiofansisland)
(Off topic but, there is a 30 day guarantee if that addon does not work for your project)
You can get any UWP meta info with this function
uwp_get_option($key);
Where the $key is the fields “htmlvar_name” prefixed with uwp_ so if you have a field with “htmlvar name” of “gender” it would be
$gender = uwp_get_option("uwp_gender");
If you simply want to show a field on the more info tab, just add the field and in the “show in what locations” option, select “more info tab”
Thanks,
Stiofan
Thread Starter
gxwpm
(@gxwpm)
This function always return null for me. I’ve tried it with different fields but result is same. I’ve tested my code for default WP functions to get some user info and it worked.
Plugin Author
Stiofan
(@stiofansisland)
Sorry, i gave you the wrong function, you want to get the user meta right?
If so it would be this function
$gender = uwp_get_usermeta( $user_id , $key = 'uwp_gender', $default );
If functions just like the WP version.
If i can help further just let me know.
Thanks,
Stiofan
Thread Starter
gxwpm
(@gxwpm)
It still doesn’t return anything. Also tried this format but no luck;
$gender = uwp_get_usermeta( $user_id , ‘uwp_gender’ , ” );
That’s a condition on one of my custom shortcodes that should return user’s gender on UWP.
elseif ( $cmd == 'uwptest' ) {
$user_id = get_current_user_id();
$gender = uwp_get_usermeta( $user_id , $key = 'uwp_gender' , $default );
return $gender;
}
Plugin Author
Stiofan
(@stiofansisland)