Users to have specific «section/roles» like Vendors

When I mean a section this is like in the admin.

Vendors have :

Vendors
Add Vendor
Categories
Régions
Attributes

And they specifically for them « Listings »

I am asking that so Users that list Requests can have a more “Complex/Details” profile.

That is basically it :slight_smile:

I hope this is “speaking” to anybody else

Thank you
Laurent

Salut Lolo,

I added a custom attribute on user called “type”.
As you can see, it shows on the login pop-up windows from the get go, and it’s a required setting :

It’s not exactly a role, but pretty much so.
Based on this value, I display “add request” button OR “add listings”.

They can’t be do both. You could extend this to your like.
Add form fields based on this value or not.

Cheers !

Salut cotasson :slight_smile:

Oh, okey, i see that we are working on the same type of project :slight_smile:

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 ! :slight_smile:

lolo

Hi,

You can try to overwrite the template in HivePress > Templates, and there is an available Attributes block. Also, check out this documentation: How to customize templates - HivePress Help Center

​I hope this is helpful to you.

Hello again all :slight_smile:

Thank you andrii for your reply but this is definitly not what i am looking for.

I managed to show/hide informations depending of user roles though so I am good on that :slight_smile:

I am jumping back on what you said cotasson.

And actually andrii’s lights as well.

Cotasson, with your “trick” the user still has to publish a listing?

In my project vendors do not post listings, they just need a profile and they apply for the “Request” that “normal users” post.

People who lists a service are “workers” and others who post requests are “employers”.

Now, in couple of posts like this one :

I read that we can allow “direct registration” for vendors and followed that note :

so I did that :

But when I go to mywebsite.com - This website is for sale! - mywebsite Resources and Information.

I am redirected to a normal login page :

And the registration popup in the same:

And I have “Required vendor attributes”.

Am I missing something ?

Thanks in advance for your replies :slight_smile:

Laurent

'lulolo :wink:

If you want to have the attributes be displayed on the login form, they need to set at the user level (as I mention earlier), not vendor’s (and set as required, as you understood).

If you want to embed the login form in a page (instead of a popup), use the following block :

image

Or with the classic editor, use this :

<!-- wp:hivepress/user-login-form {"className":"my-"} /-->

PS : Yes, you right, the hack I use is just a workaround, user are not set directly as “vendor”, but it’s fine by me : I designed my website so that only vendor (according to the “type” attribute) can publish listings (add requests is not available). And only customers can publish requests (add listings is not available).

Hope this helps !

1 Like

Thank you for your kind reply cotasson ! :slight_smile:

I must have definitely missed something and i don’t really know what but I just have the setup I described before and just have the “Age” as a required fields for vendors for my beta site.

Thanks for the embed login form but this is the same as the popup ?

We don’t have at the equivalent to directly access the “register” one ?

https://i.imgur.com/35uXNwV.png

Anyway, that is not that important, now I fill the 3 fields, username, email and password and once submitted I am directly redirected to the “profile completition” where I am “invited” to complete all the vendor custom attributes i setup.

This is why at least ONE needs to be mandatory to fully validate that form and THEN the account becomes a vendor.

I am just writing that in case that can helps anybody else to understand a bit better :smiley:

Cheers ! :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.