Support Forum
Support › MB Frontend Submission › Dashboard for logged in userResolved
Ok, since I can't get what I really want here, I am trying this a different, not elegant, but it's what I have to work with. This approach is not working either.
When I have a cpt that I have entries assigned to a "Staff" user, I try to use "Dashboard" but when I log in as them and view the dashboard, they are listed as the logged in user in the heading but they have "0" posts. They definitely are the post Author for several posts.
I am forcing the user to "2" which is indeed the ID of the Staff user. When I look at the posts on the back end, indeed they are the Author.
function change_author ( $data ) {
if ( get_post_type( get_the_ID() ) == 'announcement-cpt' ) {
$data['post_author'] = 2;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'change_author', 10, 1 );
Hi,
Thanks for sharing your solution.
I've also informed Key Master Anh Tran to create a filter hook to modify the main query of the dashboard to show posts for the specific user role.
I'm sorry but you have missed my question. Please read more carefully?
This is not to get a Role. I am trying to use Dashboard for the logged in user as explained in the documentation for how to use Dashboard.
I'm trying to use Dashboard method in the way it's written right now, not by Role.
That code is just to set the author to all the CPT posts no matter who enters the post.
Before I was able to see all posts for the logged in user. Now I can't see any posts.
I'm using the shortcode: [mb_frontend_dashboard edit_page="188"]. where "188" is the ID of the page where I have the edit form shortcode:
[mb_frontend_form id="announcement-cf" ajax="true" edit="true" submit_button="Add/Update" allow_delete="true" confirmation="Announcement was Added/Updated"]
This worked before but now all is failing.
Hi,
I think the post author does not change to the user ID 2 because the frontend submit shortcode is missing the attribute post_type
[mb_frontend_form id="announcement-cf" ajax="true" edit="true" submit_button="Add/Update" allow_delete="true" confirmation="Announcement was Added/Updated" post_type="announcement-cpt"]
You can also try to use this code, it works as well on my demo site
add_filter( 'rwmb_frontend_insert_post_data', 'change_author', 20, 2 );
function change_author ( $data, $config ) {
if ( 'announcement-cf' === $config['id'] ) {
$data['post_author'] = 2;
}
return $data;
}
Using the frontend form filter https://docs.metabox.io/extensions/mb-frontend-submission/#post-data-filters
Sir, this is SO frustrating! You STILL are not answering the question I am asking and I am at a loss as to why.
When I have a cpt that I have entries assigned to a "Staff" user, I try to use "Dashboard" but when I log in as them and view the dashboard, they are listed as the logged in user in the heading but they have "0" posts. They definitely are the post Author for several posts.
I am having no issue to change the author!! I am getting "0" posts when loading the dashboard for ANY user/author using the Dashboard. Not even "Hello World!" when I log in as admin.
Shortcode for form is: [mb_frontend_form id="announcement-cf" post_type="announcement-cf" ajax="true" edit="true" submit_button="Add/Update" allow_delete="true" confirmation="Announcement was Added/Updated"]
The ID for the page with the shortcode is "188"
The shortcode calling the page is: [mb_frontend_dashboard edit_page="188"]
What else do you need at this point?
Hi,
Can you please send us the list of plugins you’re using on your sites? Are you using Oxygen?
The Frontend Submission extension detects the shortcode in the edit page content. Oxygen stores content in a custom field, so our plugin cannot detect at the moment. I’m not sure if that’s the case.
Please try with a blank install of WP with no plugins (other than ours) and see if that bug still happens.
Hi John,
Please take a look at my screen record
https://share.getcloudapp.com/2NuP22Rm
https://share.getcloudapp.com/YEuP88KR
The code works as well on my demo site
add_filter( 'rwmb_frontend_insert_post_data', 'change_author', 20, 2 );
function change_author ( $data, $config ) {
if ( 'announcement-cf' === $config['id'] ) {
$data['post_author'] = 2;
}
return $data;
}
Yep. Using Oxygen.
I will take a look soon without other plugins but I need to use Oxygen. This is critical for my use case.
So I can't use this feature if I am using Oxygen.
Is this going to be resolved soon? How soon?
Oxygen is soon to release their 3.9 version with Metabox support.
We’ll start working on that this week. If nothing wrong, then we expect we can finish this week.
I am testing your development inside Oxygen which is my use case and I get a template shorcode string in an error box:
eyJzb3VyY2UiOiJodHRwczovL3dwLW94eWdlbi1tZXRhYm94IiwiY29tcG9uZW50IjpbeyJpZCI6MSwibmFtZSI6ImN0X3NlY3Rpb24iLCJvcHRpb25zIjp7ImN0X2lkIjoxLCJjdF9wYXJlbnQiOjAsInNlbGVjdG9yIjoic2VjdGlvbi0xLTIwOCIsIm5pY2VuYW1lIjoiU2VjdGlvbiAoIzEpIiwiY3RfZGVwdGgiOjF9LCJjaGlsZHJlbiI6W3siaWQiOjIsIm5hbWUiOiJjdF9zaG9ydGNvZGUiLCJvcHRpb25zIjp7ImN0X2lkIjoyLCJjdF9wYXJlbnQiOjEsInNlbGVjdG9yIjoic2hvcnRjb2RlLTItMjA4Iiwib3JpZ2luYWwiOnsiZnVsbF9zaG9ydGNvZGUiOiJbbWJfZnJvbnRlbmRfZGFzaGJvYXJkIGVkaXRfcGFnZT1cIjE4OFwiXSJ9LCJuaWNlbmFtZSI6IlNob3J0Y29kZSAoIzIpIiwiY3Rfc2hvcnRjb2RlIjoidHJ1ZSIsImFjdGl2ZXNlbGVjdG9yIjpmYWxzZSwiY3RfZGVwdGgiOjJ9LCJkZXB0aCI6MiwiJCRoYXNoS2V5Ijoib2JqZWN0OjE1NCJ9XSwiZGVwdGgiOjEsIiQkaGFzaEtleSI6Im9iamVjdDoxNDcifV0sImNsYXNzZXMiOnt9LCJjb2xvcnMiOnt9fQ==
Hi.
Any update on the dashboard error that every Oxygen user seems to get ? I am getting DESPERATE for this to work, after long talks about it. Oxygen Builder has released their 3.9 RC 1 and the error remains. Are you working on this for the MANY Oxygen users that purchased your plugin ?
Thanks in advance for letting us know ! I will also post on the FB page.
Hi AnLip,
The issue of MB Frontend Dashboard not working with Oxygen Builder has been fixed in the new version of MB Frontend Submission 3.1.5 or MB AIO 1.15.2.
Please update the extension and re-check it.