Home › Forums › Calendar Products › Community Events › Prevent from taking Authorship when editing community
- This topic has 8 replies, 3 voices, and was last updated 9 years, 7 months ago by
Ryan.
-
AuthorPosts
-
August 18, 2016 at 6:24 am #1153070
Ryan
ParticipantHey Guys,
I am inquiring with a question that is very similar to this thread:
I do not use BuddyPress, but my issue is the same. If a user submits an event using the community events add-on and then I, as a site admin, edit the event (to fix spacing, or correct something), the WordPress Author changes to the admin account, instead of staying linked to the user who submitted it.
I will not that I require an account to submit events, so all submissions are coming from users who have accounts.
I also have a snippet in place to show the full list of users on the Author dropdown, since by default it only shows site admins and editors. Here is that snippet for reference:
// Allow subscribers to show up in Author dropdown for events/posts add_filter('wp_dropdown_users', 'MySwitchUser'); function MySwitchUser($output) { //global $post is available here, hence you can check for the post type here $users = get_users( [ 'role__in' => [ 'subscriber', 'administrator', 'editor', 'author' ] ] ); $output = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">"; //Leave the admin in the list $output .= "<option value=\"1\">Admin</option>"; foreach($users as $user) { $sel = ($post->post_author == $user->ID)?"selected='selected'":''; $output .= '<option value="'.$user->ID.'"'.$sel.'>'.$user->user_login.'</option>'; } $output .= "</select>"; return $output; }August 18, 2016 at 4:31 pm #1153442Nico
MemberHi there Ryan,
Thanks for getting in touch with us! I’ll help you here…
Can you please let me know what user role are you assigning to new users in your site (WP-Admin > Settings > General > New User Default Role)? I’ll try to reproduce on my end hence investigate a possible fix. I’ve googled a bit about it but cannot find any firm solution so I’ll have to run some tests.
Regarding the code sent, I understand you use that as workaround for now, right? Does it work as intended?
Please let me know about it,
Best,
NicoAugust 18, 2016 at 5:36 pm #1153461Ryan
ParticipantHey Nico,
I have the default role as subscriber.
The code snippet I included works in that it shows all users in the dropdown, but the user is still switching from the person who submitted the event to the admin when the admin goes in to edit the event that was submitted.
I would probably test with and without that snippet – honestly, I had removed that snippet until recently and there was a reason I removed it, but I don’t recall what that reason was. I’d prefer not to have that snippet in there, the only reason it is in place is so I can change the author after editing since it switches to the admin and I need it to stay as the user so they can access it from their account dashboard on the front end that we have setup.
Thanks, as always!
Matt
August 19, 2016 at 4:45 pm #1153891Nico
MemberThanks for following up Matt! I fully get the issue now 🙂
Can you try to change a user to author level and see if after editing the post it also changes ownership? If this actually works could it be a solution for you?
Please let me know about it, if the above doesn’t work I’ll have to dive into the code and try to find a fix for this,
Best,
NicoAugust 22, 2016 at 6:27 am #1154312Ryan
ParticipantHey Nico,
I removed the code that was allowing me to select all users from the dropdown on the ‘Author’ field on the events page, then changed the user’s role to ‘Author’ per your suggestion. I then edited the event (as the admin) and the event’s author did stay intact.
So, that does seem to be a workable solution. It isn’t ideal that each time an event is submitted from a new user I have to go in and change the role of that user in order to allow for admin editing, but at least we have a workaround. Hopefully there is a fix in the future.
Do you see any downsides to have a user as an ‘Author’ instead of a basic ‘Subscriber’?
Thanks for your help.
Matt
August 22, 2016 at 11:37 am #1154464Nico
MemberGlad to hear Matt!
I’d say bulk edit users to change their role to author. I don’t see any downsides on this, and in fact the codex state ‘Subscriber – somebody who can only manage their profile’, so I guess this is not a bug on our side but how WordPress manages content. I guess the thing here is that ‘Suscriber’ is the default user role for new users in WordPress so most likely site admins won’t notice this. Do you think this was your case?
Do you see any downsides to have a user as an ‘Author’ instead of a basic ‘Subscriber’?
No, just be sure to block admin access in WP-Admin > Events > Settings > Access Control for the author role.
Please let me know your thoughts on this,
Best,
NicoAugust 22, 2016 at 5:49 pm #1154610Ryan
ParticipantHey Nico,
That works for me. Setting the default role to author and bulk-changing the other should resolve this.
Thanks for the guidance.
Cheers,
Matt
August 23, 2016 at 6:45 am #1154768Nico
MemberThanks for the heads-up Matt! Glad to be of service 🙂
I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.
Hope you have a great week,
Nico -
AuthorPosts
- The topic ‘Prevent from taking Authorship when editing community’ is closed to new replies.
