Home>Support>Custom Widgets with Custom Capability (User Role Editor) not saved

Custom Widgets with Custom Capability (User Role Editor) not saved

Hey there,

I got a big problem on a website.

We created lots of custom so-widgets and assigned a custom role with limited capabilities to a content-manager.

Unfortunately the content of the custom widgets does not get saved. Standard Siteorigin-Widgets get saved.

Are there any restrictions with pagebuilder that I missed? In the documentation I found nothing about custom roles.

Any help appreciated.

Kind regards,
Florian

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 6 years, 3 months ago Alex S
    Hi, I Work Here

    Hi Florian,

    To clarify, are you stating that you created your widgets using the SiteOrigin Widgets Bundle framework or via the standard WordPress widgets functionality? Would it be possible for you to link me to your GitHub or provide us with a copy of your code so we can take a look over it? Or are you stating this issue relates to the standard SiteOrigin widgets?

    Regardless of the above, there aren’t any restrictions set in place, the only real requirement is that the user needs to be able to edit the post in general. How are you adding this custom user role?

  2. 6 years, 3 months ago fsm_office

    Hi Alex,

    to create the widgets we use the SiteOrigin Widgets Bundle framework. The code is not on GitHub, but here is a Gist:

    Gist of widget code

    Widgets shipped with the PageBuilder work as expected, they get saved as normal. Strange thing is, you see the Content in the “Edit Post”-Screen, but in the frontend the default values of the widget appears. If you switch back from to the WordPress-Editor (revert to editor) you see the SO-Shortcodes but without content.

    We are adding the custom role via the plugin “Members”.

  3. 6 years, 3 months ago Alex S
    Hi, I Work Here

    Hi,

    Is there a template file I can take a look at?

  4. 6 years, 3 months ago fsm_office

    Hi Alex,

    I updated the Gist with the template file.

  5. 6 years, 3 months ago Alex S
    Hi, I Work Here

    Hi Fsm_office,

    Just to confirm, did you mean to omit <?php on the first line of the template file?

    Regardless, this appears to be happening due to the following PHP in application-text.php:

    function get_template_variables( $instance, $args ) {
    	return array(
    	);
    }
    

    Please either remove that method, or return $instance rather than an empty array.

  6. 6 years, 3 months ago fsm_office

    Hi Alex,

    Yes, the PHP-Tag was a typo. Sorry for that.

    I changed the method to return the instance, but also this does not solve the problem.

  7. 6 years, 3 months ago Alex S
    Hi, I Work Here

    Hi Fsm_office,

    That’s odd – that helped me. Can you please update the provided gist with the changes you’ve made?

  8. 6 years, 3 months ago fsm_office

    Hey Alex,

    sorry for the delay, I updated the gist.

  9. 6 years, 3 months ago fsm_office

    Hi again,

    I also noticed the Shortcode-Content is empty if you switch back to the text-editor

  10. 6 years, 3 months ago Alex S
    Hi, I Work Here

    Hi Fsm_office,

    Thanks. The provided version works without issue for me. Can you please provide me with a full copy of your plugin? I suspect the reason why it’s not working could becoming elsewhere. Also, please double check to ensure you’re using the latest version of SiteOrigin Page Builder and the SiteOrigin Widgets Bundle.

    For reference, here’s what the shortcode looks like for me.

  11. 6 years, 2 months ago fsm_office

    Hi Alex,

    thanks for your help. The Code resides in a Custom Theme.

    I think its a Problem with Roles and Capabilities, either the Plugin “Role Manager” or the WordPress-Capabilities not mapped right.

    I try to check the capabilities again and maybe hardcode them all without a plugin.

    However, you do a great job at SiteOrigin, it is my favourite composer and also your support is very nice!

    Thank you again :)

  12. 6 years, 2 months ago Alex S
    Hi, I Work Here

    Hi Fsm_office,

    Thank you for the kind words! :)
    Let me know how you go mate.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More