WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
[resolved] new capabilites for subheading (8 posts)

  1. babyoth
    Member
    Posted 1 year ago #

    I'm using a the plugin called horizontal scrolling and I want the editor role to be able to see this settings page and not all the others settings under the setting subheading (general, writing...)

    Is anyone able to help me with this?

    So far I have added a new capability called manage_announcements but dunno what to do next

    http://wordpress.org/extend/plugins/user-role-editor/

  2. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    At line #306 of horizontal-scrolling-announcement.php file plugin author defines 2 menu items under 'Settings' menu:

    add_options_page('Horizontal scrolling announcement', 'Horizontal Scrolling', 'manage_options', __FILE__, 'HSA_admin_options' );
    	add_options_page('Horizontal scrolling announcement', '', 'manage_options', "horizontal-scrolling-announcement/horizontal-scrolling-setting.php",'' );

    It is impossible to leave them under 'Settings' menu and give access to them without access to others 'Settigns' menu items, as all of them use the same capability - 'manage_options'.
    You can achieve your purpose just via modifying this plugin to use separate own menu with its own capability, e.g. 'manage_announcements'.
    Let me know if you decide to proceed this way.

  3. babyoth
    Member
    Posted 1 year ago #

    that sounds like what i'm looking for, could you give me more info on how I would do this please

  4. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    As plugin shows only one menu item, I think that creating new submenu to it is too much. Let's move 'Horizontal Scrolling' menu item from the 'Settings' menu to the 'Tools' menu. As 'Tools' menu is available for all users you can limit access to the 'HS' menu item easy. What you should do?
    change lines above to

    add_management_page('Horizontal scrolling announcement', 'Horizontal Scrolling', 'manage_announcements', __FILE__, 'HSA_admin_options' );
    	add_management_page('Horizontal scrolling announcement', '', 'manage_announcements', "horizontal-scrolling-announcement/horizontal-scrolling-setting.php",'' );

    Also you need to replace all occurrences of 'options-general.php' to the 'tools.php':
    line #156 should become:

    $mainurl = get_option('siteurl')."/wp-admin/tools.php?page=horizontal-scrolling-announcement/horizontal-scrolling-announcement.php";

    line #285:

    <td align="left" valign="middle"><a href="tools.php?page=horizontal-scrolling-announcement/horizontal-scrolling-announcement.php&DID=<?php echo($data->hsa_id); ?>">Edit</a> &nbsp; <a onClick="javascript:_hsadelete('<?php echo($data->hsa_id); ?>')" href="javascript:void(0);">Delete</a> </td>

    Lines 2,3 at button.php waits for your intervention with the same replace of 'options-general.php' with 'tools.php' too.

  5. babyoth
    Member
    Posted 1 year ago #

    worked thanks, would be great if i could move it to media section, tried changing tools.php to upload.php but didn't seem to change from tools section

  6. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    Replace add_management_page() to add_media_page() additionally to change tools.php on upload.php and menu item will be moved to the 'Media' menu.

  7. babyoth
    Member
    Posted 1 year ago #

    thanks, it works perfectly now :-)

  8. babyoth
    Member
    Posted 1 year ago #

    just tried to delete an announcement and i got this error message

    "Fatal error: Cannot redeclare horizontal_scrolling_announcement() (previously declared in C:\Users\Jenny\xampp\htdocs\Wordpress\wp-content\plugins\horizontal-scrolling-announcement\horizontal-scrolling-announcement.php:20) in C:\Users\Jenny\xampp\htdocs\Wordpress\wp-content\plugins\horizontal-scrolling-announcement\horizontal-scrolling-announcement.php on line 58"

    is this because of something we did? because it worked fine before, i believe

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.