Commit 8ed2e3ff authored by Romain Duminil's avatar Romain Duminil

#42 Modification des projets impossible pour non auteur

parent b3504bbe
......@@ -33,6 +33,7 @@ class CommunityProject
add_action( "add_meta_boxes", array( $this, "add_custom_fields" ) );
add_action( "admin_menu", array( $this, "remove_meta_boxes" ) );
add_action( "admin_menu", array( $this, "redirect_if_not_author" ) );
add_action( "do_meta_boxes", array( $this, "remove_edit_flow_metabox" ) );
add_action( 'save_post', array( $this, 'set_default_status' ) );
add_action( 'after_setup_theme', array( $this, 'remove_admin_bar') );
......@@ -43,6 +44,17 @@ class CommunityProject
new ShortcodeController();
}
function redirect_if_not_author()
{
if ( isset( $_GET['post'] ) && $_GET['action'] === 'edit' )
{
if( ! current_user_can( 'publish_posts' ) && get_post()->post_author != get_current_user_id() )
{
wp_redirect( admin_url() );
}
}
}
function remove_admin_bar() {
if ( current_user_can( 'student_role' ) && ! is_admin() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment