Making the cost of request the same

Hey I want to disable the budget field on Request and make the budget $20 for everyone.
Here’s what I did to start with

//Disable the budget field in the request
add_filter(
	'hivepress/v1/models/request/attributes',
	function( $attributes ) {
		if ( isset( $attributes['budget'] ) ) {
			$attributes['budget']['edit_field']['value'] = 20;
			$attributes['budget']['display_format'] = '';
			
			//Make the budet field invisible on the send request form. 
			$attributes['budget']['editable'] = false;
			$attributes['budget']['filterable'] = false;
			$attributes['budget']['edit_field']['required'] = false;
		}
		return $attributes;
	},
	1000
);

I’ve made the budget field disappear and made the value 20. However, I need to press the update button on each request in order to make this value updated.

Is there anyway where budget gets updated autmatically?

Please try this PHP snippet

add_filter(
	'hivepress/v1/models/request/create',
	function( $request_id, $request ) {
		if(hivepress()->get_version('marketplace')){
			$request->set_budget(20)->save_budget();	
		}
	},
	1000,
	2
);

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