• Resolved PC-Rider

    (@pc-rider)


    Hello Nik,

    Can I add editors to manage the news plug-in?

    I tried and can change from administrator to editor by changing this line:

    function scrollnews_plugin_menu(){
    
            add_menu_page(__('Scroll news'), __("Beheer Rollend Nieuws"),'editor', 'Scrollnews-settings','managenews');
    
          }

    But I want them both to be able to manage the plug-in, now admins can’t change the plug-in.

    Any possibilities?

    Thanks in advance,

    Anno

    https://www.ads-software.com/extend/plugins/vertical-news-scroller/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Nks

    (@nik00726)

    Hello Try given bellow code.You have to to conditional code for role.

    function scrollnews_plugin_menu(){
    
              $userRoles=vertical_news_scroll_get_user_role();
    
             if($userRoles=='administrator'){
    
                    add_menu_page(__('Scroll news'), __("Manage Scrolling News"), 'administrator', 'Scrollnews-settings','managenews');
             }
             elseif($userRoles=='editor'){
    
                 add_menu_page(__('Scroll news'), __("Manage Scrolling News"), 'editor', 'Scrollnews-settings','managenews');
    
             }   
    
          }
    
          function vertical_news_scroll_get_user_role($id=null){
                global $current_user;
                if(!$id) $id = $current_user->ID;
                    if ( is_user_logged_in() ) {
                       $user = new WP_User( $id );
                    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
                     foreach ( $user->roles as $role )
                     return $role;
                    }
                }
            }

    Please rate this plugin if you found useful.

    Thanks

    Thread Starter PC-Rider

    (@pc-rider)

    Hello Nik,

    Your supposed extra code works for me now, Thanks! I just translated “Manage scrolling News” into Dutch, see my first posting.

    I suppose I can add other role line in the “if”-“elseif” loop to extend the user that can edit the plugin.

    Thanks, I’ll go and rate your pluin now!

    Anno

    Plugin Author Nks

    (@nik00726)

    Thanks for rating Anno.

    yes,You can do If-elsif for other roles.

    Thanks

    Hi Nik,

    thanks for the plugin and your extra code. Worked fine!

    Wormo

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘add editors to manage News’ is closed to new replies.