Hi All,
Folks who use GeoDirectory on my site register and are thereby assigned one of the following user roles automatically: first_user_role, second_user_role, third_user_role (access to/ restriction of content happens through permissions rules associated with roles). Then, I have a few post types e.g. gp_place and always three corresponding categories first_user_category, second_user_category and third_user_category.
Now, each user type should only be able to post in his/her category. If the user role changes (upgrade/downgrade of role) the already published posts and any new post should again match the corresponding category (e.g. first_user posts in first_user_category of gp_place, etc.).
Now, I read https://wpgeodirectory.com/support/topic/set-default-category/ and https://wpgeodirectory.com/support/topic/autofill-category/ which if I understand correctly, should enable automatic selection of category depending on package selection on the add-listing page. This would basically allow me to align a user role to a package and via package to the category, correct? But in my case I actually do not want to have the user select a package, because it is already clear that first_user has first_user_package and thus posts in first_user_category etc. (because here again we have corresponding first_user_package, second_user_package, third_user_package set up). How would the set-default-category code have to be altered anyway?
<script>
jQuery(document).ready(function(){
if(location.pathname == "/add-listing/")
{
jQuery('#gd_placecategory.chosen_select').val('9').change();
setTimeout(function()
{
jQuery('input[name = post_default_category][value = 9]').attr("checked", "checked");
}, 2000);
}
});
</script>
But, instead of going through the extra layer of creating and later selecting a package and based on the package selecting a category and automating this selection via script, couldn’t it be done much simpler using a function whereas first_user_category and first_user_package for all posts always corresponds to first_user_role?
Thank you for your help!