Salut cotasson
Oh, okey, i see that we are working on the same type of project
In fact i was asking for that hoping to make things simplier.
I saw that post :
And like i shared here for a repeater and shortcode for the “Listing” Page/Template
I’d like to do the same but for users.
I am trying to create a custom “User” page and i need to retreive all attribute as shortcode.
But so far i just manage to do it but it shows the custom attribute of the loggued user.
Not the user profil we are browsing : (and of course you dont see anything if you are not logged)
add_shortcode('show_user_attribute', function($atts) {
// Allow manual override with user_id parameter
$atts = shortcode_atts([
'user_id' => null
], $atts);
$user_id = null;
// If specific user_id is provided in shortcode
if ($atts['user_id']) {
$user_id = intval($atts['user_id']);
}
// If on user profile page, get that user's ID
elseif (is_singular('hp_user')) {
$user_id = get_post_meta(get_the_ID(), 'hp_user', true);
}
// Otherwise get current logged-in user
else {
$user_id = get_current_user_id();
}
if (!$user_id) return '';
return get_user_meta($user_id, 'hp_user_test_attribut', true);
});
which if far to be looking good anyways…
I was hoping to have something similar than :
$listing = \HivePress\Models\Listing::query()->get_by_id($listing_id);
Like :
$user = \HivePress\Models\USer::query()->get_by_id($user_id);
But i cant get what i want :-/
Cheers too !
lolo