Frontend submission lis: tIs it possible to list the posts from all users?

Support MB Frontend Submission Frontend submission lis: tIs it possible to list the posts from all users?Resolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #39311
    picatabaibospicatabaibos
    Participant

    Hi,

    Is it possible to list on user dashboard all the posts from all users? I'm trying to create a frontend submission for a custom post type (news), but every editor should have access to all news so they can edit.

    https://docs.metabox.io/extensions/mb-frontend-submission/?swcfpc=1#user-dashboard

    Let me know please.

    Thank you

    #39335
    PeterPeter
    Moderator

    Hello there,

    Yes, it is possible. The posts in the frontend dashboard are retrieved by a WP Query, and there is a filter hook rwmb_frontend_dashboard_query_args that supports modifying the arguments. Please read more on the documentation https://docs.metabox.io/extensions/mb-frontend-submission/#dashboard-hooks

    Here is an example code:

    add_filter( 'rwmb_frontend_dashboard_query_args', function( $args ) {
        // Get the user role
        $current_user_id = get_current_user_id();
        $user_meta = get_userdata( $current_user_id );
        $user_roles = $user_meta->roles;
    
        // Check if the user has an editor role, remove the argument author
        // see here https://developer.wordpress.org/reference/classes/wp_query/#author-parameters
        if( in_array( 'editor', $user_roles, true ) ) {
            unset( $args['author'] );
        }
    
        return $args;
    } );
    #39346
    picatabaibospicatabaibos
    Participant

    Wow, fantastic Peter, thank you so much!

    #39347
    picatabaibospicatabaibos
    Participant

    Oh by the way, if possible I have another (unrelated) question:

    - Can we create a register and edit user form on front end?
    - Can we create a dashboard page for user?

    Have a great weekend.

    Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.