Join our new community forum for support & discussion
Join Nowrequests
-
AuthorPosts
-
DDV 9 months, 1 week ago
Hi, Ihor. How can i limit the number of requests from one user?
Since I’m still waiting for the introduction of paid packages for posting requests to the site, I would like to limit the posting of queries to 1 or 2, but only for users, not vendors.
Thanks in advance:)DDV 9 months, 1 week agoAnd one more question about advertising ads. Where can I configure, perhaps with a snippet, that ads with ads are automatically sorted into the first rows on the ads page.
I have them all over the page, the only thing that makes them stand out is the frame, but I would like to make a clear advantage in the form of a guaranteed location in the first rows.
1) Please try this PHP snippet
add_filter( 'hivepress/v1/forms/request_submit/errors', function ( $errors, $form ) { if(!current_user_can('edit_posts')){ $request_count = \HivePress\Models\Request::query()->filter( [ 'status__in' => [ 'private', 'publish' ], 'user' => get_current_user_id(), ] )->get_count(); if($request_count >= 2){ $errors[] = 'You have exceeded limit of 2 requests'; } } return $errors; }, 1000, 2 );
2) Please make sure that number of featured listing per page is not equal zero. Then featured listing will be in the top on each page. You can check this setting in HivePress/Settings/Listings section
DDV 9 months agoHi Yevhen. Everything works great, you’re super. By the way a question arose, and if it will be necessary to limit requests for sellers, what status to change in the snippet?
DDV 9 months agoAnd ran into a problem, in the editor on the main page in the block Category, I can put 4 columns in a row, but when you save the site shows 3 columns in a row and one in the second row. In the editor, all 4 columns in a row. How can I fix to have all 4 ad categories in one row?
1) You can try this PHP snippet to add request restriction for both sellers/vendors and users
add_filter( 'hivepress/v1/forms/request_submit/errors', function ( $errors, $form ) { $request_count = \HivePress\Models\Request::query()->filter( [ 'status__in' => [ 'private', 'publish' ], 'user' => get_current_user_id(), ] )->get_count(); if($request_count >= 2){ $errors[] = 'You have exceeded limit of 2 requests'; } return $errors; }, 1000, 2 );
2) Please check block settings when you edit home page. Please try to set number 4 in
Columns
select field and set number 4 inNumber
fieldDDV 9 months agoWonderful, thank you very much.
The categories are sorted out. I was changing the styles for 3 categories and when I did 4 there were problems, all fixed:)DDV 8 months, 3 weeks agoYevhen, hi. I have a question today about the snippet.
I limited the number of queries for all, with this snippet:add_filter(
‘hivepress/v1/forms/request_submit/errors’,
function ( $errors, $form ) {
$request_count = \HivePress\Models\Request::query()->filter(
[
‘status__in’ => [ ‘private’, ‘publish’ ],
‘user’ => get_current_user_id(),
]
)->get_count();if($request_count >= 2){
$errors[] = ‘You have exceeded limit of 2 requests’;
}return $errors;
},
1000,
2
);The question is, can I somehow remove restrictions for users who are verified (i.e. have a PRO badge) ?
Thank you in advance:)Please try this PHP snippet
add_filter( 'hivepress/v1/forms/request_submit/errors', function ( $errors, $form ) { $verified_users = \HivePress\Models\Vendor::query()->filter( [ 'verified' => true, 'status' => 'publish', ] )->get(); $verified_user_ids = array_map(function($vendor){ return $vendor->get_user__id(); }, (array)$verified_users); if(!in_array(get_current_user_id(), $verified_user_ids)){ $request_count = \HivePress\Models\Request::query()->filter( [ 'status__in' => [ 'private', 'publish' ], 'user' => get_current_user_id(), ] )->get_count(); if($request_count >= 2){ $errors[] = 'You have exceeded limit of 2 requests'; } } return $errors; }, 1000, 2 );
DDV 8 months, 2 weeks agoYevhen is awesome. Thank you very much it will help me a lot.;)
-
AuthorPosts
New Reply
This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.