Wsparcie » Wtyczki » Menu wtyczki

  • Witam,

    mam takie coś :

    function video_menu() {
       add_menu_page( 'Video','Video', 'administrator', 'video', 'video_page', plugins_url( 'video/img/youtube.png' ),7);
       add_submenu_page( 'video', 'Video', '+ / - film', 'administrator', 'video', 'video_page' );
       add_submenu_page( 'video', 'Video', 'Ustawienia','administrator', 'video-setting', 'video_options' );
    	}
    add_action( 'admin_menu', 'video_menu');

    I teraz chciał bym żeby Użytkownicy z grupy „Redaktor” też mieli dostęp do tej wtyczki, poradzicie coś ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Musisz stworzyć nowe capabilities i przypisać je dla redaktora.

    function add_theme_caps() {
        // gets the author role
        $role = get_role( 'author' );
    
        // This only works, because it accesses the class instance.
        // would allow the author to edit others' posts for current theme only
        $role->add_cap( 'edit_my_posts' );
    }
    add_action( 'admin_init', 'add_theme_caps');
     add_submenu_page( 'video', 'Video', 'Ustawienia','edit_my_posts', 'video-setting', 'video_options' );
    Thread Starter freedom.street

    (@freedomstreet)

    Zrobiłem jak powiedziałeś ale mam błąd :

    Call to undefined function add_submenu_page()

    🙂 F1 ? 🙂

    To pokaż całość.

    Thread Starter freedom.street

    (@freedomstreet)

    // rejestrujemy style w panelu admina
    function video_theme() {
        wp_enqueue_style('video-theme', plugins_url('../css/style.css', __FILE__));
    }
    
    add_action('admin_enqueue_scripts', 'video_theme');
    add_action('login_enqueue_scripts', 'video_theme');
    
        // menu wtyczki
    function video_menu() {
       add_menu_page( 'Video','Video', 'administrator', 'video', 'video_page', plugins_url( 'video/img/youtube.png' ),7);
       add_submenu_page( 'video', 'Video', '+ / - film', 'administrator', 'video', 'video_page' );
       add_submenu_page( 'video', 'Video', 'Ustawienia','administrator', 'video-setting', 'video_options' );
    	}
    add_action( 'admin_menu', 'video_menu');
    
    function video_page() {
       if ( !current_user_can( 'manage_options' ) )  {
       wp_die(__( 'oj.. chyba oszukujemy co ?' ) );
       }
       include 'template.php';
    }
    
        //strona ustawien video
    function video_options () {
       if ( !current_user_can('manage_options')) {
           wp_die(__('Oj.. chyba oszukujemy co ?'));
       }
       include 'video-setting.php';
    }
    
        //strona ustawien video
    function video_options_u () {
       if ( current_user_can('manage_options')) {
           wp_die(__('Oj.. chyba oszukujemy co ?'));
       }
       include 'video-setting.php';
    }

    Co źle ? 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • Temat ‘Menu wtyczki’ jest zamknięty na nowe odpowiedzi.