Permalinks field always required

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 10, 2019   (RSS)

By gversion - June 5, 2019

Hello,

I am using the permalinks plugin and there is a "permalink" field on my CMSB accounts table.

The problem is that this field is always required even if a user should not have a permalink.

I have not ticked the "required" checkbox (user may not leave field blank) in the section editor settings.

Can someone please assist? I would like to stop having to enter a permalink for a user when I need to make an update to their account details.

Thank you,

Greg

By gversion - June 7, 2019

Hi Daniel,

Thanks for the reply.

I use the permalink to display all listings for a user (e.g. www.mywebsite.com/username) however I would like to only require a permalink if the user is on a subscription (cmsb_subscription). If the user does not have a subscription selected then the permalink should not be required.

If the above is too tricky to achieve without modifying the plugin then I would really appreciate it if you could offer me the solutions you can think of and then I will try to work with them.

One solution could be to just set the permalink for all users that register though I am not sure how to do this.

Thanks again,

Greg

By daniel - June 10, 2019

Hi Greg,

One feature that the Permalinks plugin offers is automatic permalink generation, which may be helpful in your situation. This can be set up using the configuration options at the top of permalinks.php. If you want to auto-populate using the "username" field, it would look something like this:

$GLOBALS['PERMALINKS']['autopopulate']            = true;
$GLOBALS['PERMALINKS']['autopopulate_fromFields'] = array('username'); 

The result of this is when the permalink field is left blank when saving a record, the plugin will look for a field called "username" - if it exists that value will be used to create the permalink. Note that if you're already using this feature for other tables, you'll want to add the 'username' field to the array rather than replace existing items.

Further, to restrict non-subscribed members from having a permalink, you can check for the "cmsb_subscription" field on the display page and display a warning/error instead of the listings if they are not subscribed. In this way, any user may have a permalink but only subscribed members can use it.

Let me know if you have any luck with this approach, or if you have any more questions!

Thanks,

Daniel
Technical Lead
interactivetools.com