[e-Newsletter] Custom User Role for enwsletter tasks

Hi,

We use Custom User Profile to create an extra user role. We want some of our users to be able to generate newsletters.
We got it working, but not perfectly. They need to be able to copy an existing newsletter. They have access to the newsletter dashboard, but there is it only possible to edit, delete or send a newsletter.
We can't achieve it to give them access /wp-admin/admin.php?page=newsletters
On that page there is a clone button available. Or is it possible a clone button is added on the dashboard?

We now assigned these rights to the role:
create_newsletter
delete_newsletter
save_newsletter
send_newsletter
view_newsletter_dashboard

Kind regards, Age

  • Adam Czajczyk
    • Support Gorilla

    Hi jongag1

    I hope you're well today and thank you for your question!

    There's more capabilities used by the plugin to allow/disallow various actions but in order to let users access the "newsletters" page and the "clone" option you'd need to make sure that at least these three are assigned to the user role:

    create_newsletter (it's already there, so it's fine)
    save_newsletter (that one is there as well)
    save_newsletter_settings (this one has to be added)

    Unfortunately, adding that last one will not only allow access to the "newsletters" page but will also "unlock" the "Settings" page where such user will be able to make changes to the E-Newsletter configuration.

    Is it fine for you or would you rather keep these users away from it? If so, we'd need some additional code for this so the capability would have to be granted and the PHP code would block the access.

    Best regards,
    Adam

  • jongag1
    • The Crimson Coder

    Hi Adam,

    I added that save_newsletter_settings in the userrole to test it, but it isn't working. Permision denied when opening /wp-admin/admin.php?page=newsletters

    But if it was, it isn't the perfect solution because I don't want them to be able to make changes into the configuration form E-Newsletter.

    With kind regards,
    Age

  • jongag1
    • The Crimson Coder

    Hi Adam Czajczyk,

    I inserted the below code in the file page-newsletters-dashboard.php on line 146

    <a href="?page=newsletters&newsletter_action=clone_newsletter&newsletter_id=<?php echo $newsletter['newsletter_id'];?>">
    <input class="button button-secondary" type="button" value="<?php _e( 'Clone', 'email-newsletter' ) ?>" />
    </a>

    It now shows the clone button on the dashboard page, but clicking on it gives a message the user has inadequate rights to view the page at wp-admin/admin.php?page=newsletters&newsletter_action=clone_newsletter&newsletter_id=66

  • Adam Czajczyk
    • Support Gorilla

    Hi jongag1

    Yes, it has to be primary role, I should have been more specific but somehow I didn't think that you might be using secondary roles - it's more rarely used than it seems :wink:

    I'm glad that you got that working but just wanted to ask: is it still with the change in the code? I'm asking because changing the core code is never recommended as it will be gone upon plugin update, might cause some unexpected issue in a long run and it might also turn out that with one of the future update it won't be possible to re-apply the very same change because of the change in the core code. If you can get it running without that change then even if they would be able to access settings - it would be better because we could then deal with that part in the next step and forbid that access in a different way :wink:

    But that's up to you of course and if you're fine with the way it currently is that's perfectly fine. I'll be ready to "jump back in" in case you'd like to give a try to other ways :slight_smile:

    Best regards,
    Adam

  • jongag1
    • The Crimson Coder

    Hi Adam Czajczyk,

    I just inserted the Clone button into the dashboard. Nothing else was changed so it should not be a problem if it would be overwritten during an update.
    Though, adding the Clone button into the dashboard op E-newsletter would be a nice change for you guys to implement.

    It's not necessary to give permissions to the Settings page. only permissions the user now have are:
    create_newsletter
    delete_newsletter
    read
    save_newsletter
    send_newsletter
    view_newsletter_dashboard

    Thanks,
    Ager

  • jongag1
    • The Crimson Coder

    Sorry Adam Czajczyk,

    I thought it was okay when the user was able to see the menu links. Tested cloning a newsletter and that was working. So I assumed everything was okay. But now I found out it isn't.
    After cloning/or creating a newsletter editing the newsletter comes up with an almost empty screen.

    I tried adding save_newsletter_settings to the user-role but that doesn't solve it.
    Do you have an idea?

    With kind regards,
    Age

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.