JoshLewis Posted August 26, 2020 at 09:11 PM Share Posted August 26, 2020 at 09:11 PM (edited) I have a listing category where it's ideal for new listings to go to a specific member, but want all other categories to keep the original author. Utilizing listing_save_pre this can be accomplished: function assign_user($data, $params) { // Check category id if ( $data['Listing']['catid'] == 6 ) { $data['Listing']['created_by'] = 5; // assign listings created in catid 6 to user #5 } return $data; } Clickfwd\Hook\Filter::add('listing_save_pre', 'assign_user', 10); Other listing variables can be used for condition(s) to check and assign: https://www.jreviews.com/docs/theme-resources/discover-data-available-in-templates#listing-variables Just be sure to use dd($data) and properly map out the arrays given slight differences in listing variables to $data[] array. Always test before actually saving the data which is another huge benefit of the dd() function. Reviews also have their own save pre, hence it's possible to do the same for reviews. Edited August 26, 2020 at 09:13 PM by JoshLewis Alex.1, Alejandro and n00bster 1 2 Link to comment
n00bster Posted August 27, 2020 at 08:32 AM Share Posted August 27, 2020 at 08:32 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted August 27, 2020 at 10:10 AM Share Posted August 27, 2020 at 10:10 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
JoshLewis Posted August 27, 2020 at 06:03 PM Author Share Posted August 27, 2020 at 06:03 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. n00bster 1 Link to comment
Recommended Posts