by
KK » Thu Jul 09, 2015 5:41 pm
Hello and welcome, Simon

I'm glad you liked Couch.
You mentioned -
I have set up myself as Super Admin. I have also set up an Authenticated User account to be used by an editor/client.
I think you meant the plain 'Admin' account for the editor ( Usually this is the site-owner). Only super-admin and admin are allowed access to the admin-panel (and hence, by extension, to front-end editing).
Anyway, replying to your query -
What I really want is the editor/client (Authenticated User) to be redirected to the homepage after login. I'm hoping they can just use the frontend editing without needing to see the backend.
As I said, the second (i.e. admin) account is meant for the site-owner so usually there is no need to hide the admin-panel from him. Therefore, out-of-the-box, Couch does not provide any method to do so.
However, if you really must do it we can use a little work-around. Let me explain.
We build upon two behaviors of Couch -
1. When you login into the admin-panel, Couch always displays the listing of the very first template (whatever that might be).
2. We can use a custom admin-screen (essentially just an ordinary template) for any template.
(you might want to see the docs at
http://www.couchcms.com/docs/concepts/d ... forms.html if you need more info about custom admin screens. Scroll down and you'll get a section by this name).
So what we'll do is, create a dummy clonable Couch template (say named 'redirect.php') and associate it with a custom admin screen. In the custom screen we'll put our logic of checking if the logged-in user is a simple admin and redirect her to the site if so.
We'll make our dummy template the very first template listed in the sidebar so whenever someone logs in Couch tries to display the custom screen. The code in the custom screen then does the redirect.
Don't worry it will be easier to actually do than to explain. Just follow the instructions below.
1. We'll begin by creating a dummy template named redirect.php.
Put just the following into it -
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template clonable='1' order='-10'>
</cms:template>
<?php COUCH::invoke(); ?>
Register it by visiting it as super-admin.
Coming back to the admin-panel you'll find that it is listed as the very first template in the sidebar (the negative value we used with the 'order' parameter in the template's definition does this).
2. Associate a custom admin screen with this template by adding the following line of code to your 'couch/addons/kfunctions.php' file (you might have to rename 'kfunctions.example.php' to 'kfunctions.php') -
- Code: Select all
$FUNCS->register_admin_listview( 'redirect.php', 'my_redirect.html' );
Now when you'll access the admin-panel, it should show you an error message like
ERROR: Unable to get contents from custom list_view snippets/my_redirect.html
That is because it is now trying to read 'my_redirect.html' from your snippets folder to show it here but we have not placed any such file. So let us do that -
3. Create a file named 'my_redirect.html' and place it in your snippets folder (by default it is 'couch/snippets'). Put the following code into it -
- Code: Select all
<cms:if k_user_access_level lt '10' >
<cms:redirect k_site_link />
</cms:if>
As you can see, the code above simply checks if the user is not the super-admin (i.e. will be admin) and redirects her to the main site.
Test it out by trying to log as a normal admin.
Hope it helps. Do let us know.