Getting attribute value on listing submit

Hello,

I am trying to set one of my attributes automatically on listing submission. It’s called first_price and it’s not shown to the user at all. What it should do is just to be set to the same value that is price attribute is set to.

I am using this code snippet to set the value:

add_action(
    'hivepress/v1/models/listing/create',
    function( $object_id, $object ) {
		update_post_meta($object_id, 'hp_firstprice', 1000);
    },
    10,
    2
);

It works perfectly fine. However, I need to set it to a specific value provided by user. The listing object ($object) does not have the attribute values at the point when code is executed. Same way, I don’t see them anywhere in the request context.

So the question is, how do I get the price value at the point when this hook is called?

Thank you in advance!

Did you ever find a solution for this?

No, just stopped using this plugin :slight_smile:

Sorry for the delay, the topic somehow got lost in the queue. The snippet seems ok, but if you want to set the value provided by the user you can simply make this attribute editable (there’s an option in the attribute settings). If there’s another reason, you can use the hivepress/v1/models/listing/update hook, and check if the value you’re looking for is finally set, and then set the target value.

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