JoshLewis 21 Posted August 26, 2020 Share Posted August 26, 2020 (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 by JoshLewis Alejandro and n00bster 1 1 Link to post
n00bster 25 Posted August 27, 2020 Share Posted August 27, 2020 This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to post
Alejandro 877 Posted August 27, 2020 Share Posted August 27, 2020 This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to post
JoshLewis 21 Posted August 27, 2020 Author Share Posted August 27, 2020 This section is only visible with a valid subscription. If you have a valid subscription, please login. n00bster 1 Link to post
Recommended Posts