Need a way to gate content on my webpage in Drupal 8 - drupal

I wanted to gate content on my site using web forms module just like how QUORA/glassdoor does. I would want only logged in users to see all content and non logged in users should be shown a form to fill based on which user should be shown the actual content, have no coding experience. Have a bit of idea on the editor side though.
Please help! Thanks

You can restrict whether content may be viewed by anonymous visitors by changing the setting in /admin/people/permissions > View published content.
By default they will see an "Access denied" message.
There are many ways to achieve redirecting anonymous visitors to a login page or form when they visit a page they don't have access to.
One way would be to use a module like anonymous_login: https://www.drupal.org/project/anonymous_login
Screenshot of Home > Administration > People > Permissions > View published content

Related

wordpress: Redirect homepage

The homepage of my Wordpress site is set to display my latest posts.
I also created a landing page which includes a form for users to fill out for a free consultation.
How can I make it so that when first-time users go to the homepage, they will be redirected to the landing page? (But clicking on my site logo should still take them back to my regular homepage showing my latest posts.)
After users have filled out the "get a free consultation" form on my landing page, we would create a cookie or something so that whenever they next visit the homepage, they will just see the regular homepage with latest posts - not see the landing page any more.
Is there a way to write a code for this?
Thanks in advance!!!
setcookie() is probably a good option.
if(!$_COOKIE["been_here_before"]) {
setcookie("been_here_before", true);
header('Location: /consultation'); // Your free consultation page
}
The way to achive this is a little bit more complicated.
The best practice for this is to have your form in an overlay on the homepage, the user sees the form when accessing your website but has an option to close that layer (exemple:"already fiiled the form..."). After the user submits the form or clicks "close" then set a session variable that will be used so the user won't receive the overlay again in that session. An website that does that is this one which asks the user to register for the newsletter. If the user is already register then he can click "Already registerd?" (=Sunteti deja înregistrat?) and the overlay disapears for that session.
If the form submision is mandatory for all users to get access to the website, then force them to login in the landing page. Here is an example for that.

Drupal 6: Want to remove access restrictions on a View

I have a View with a Page display that only allows the returned data to be linked if the user is authenticated/logged in.
I simply want to remove that restriction. There is another view that looks the same except it's for Public and shows all the same data but not linked. (the data are pdf files).
On the authenticated display, next to Access in the Basic Settings it has: authenticated user. If I click that user role (not the gear for options), then I'm allowed a list of:
Domain
None
Permission
Role
…for access restrictions. I click "None", save. But, the links are not there as an anon visitor. Same if I try by changing the user to Anonymous User. Note: In the permissions, anon has the right to see webfm attachments.
I noticed the url is like: documents-public or documents-auth so I made it just documents. No luck.
I visited the actual custom-page-type which puts the View in a content pane. I re-ordered the variants, removed all Selection Rules and that didn't do anything either.
Flushed all caches.
Somewhere, the view is still only showing a view based on whether a user is authenticated or not even though I've removed the access (it says "unrestricted" next to access) on both displays and removed all selection rules on the actual page.
I'm stuck where else to look.
The setting you're changing (Access restrictions) is for the entire page - the page URL will return a 403 error if the criteria are met.
As to where the logic is to display/not display the link, four things come to mind:
If the "view mode" is set to node or teaser, it could be in the node template file.
The logic might be in a specific view template (click on the theme information link and see if any of the templates have been overridden).
The developer might have user Views Custom Fields to put the logic directly in the fields.
The linked content is actually restricted.
I'm sure there are other possibilities too. The main point here though is that if access was restricted for anon users, they would see a 403 error, not just some missing fields.

WordPress multi-user site to allow unique users to see custom screens

So I need to set up a WordPress site with 25 users. The site will be for each of these users to fill out various forms (different forms for each user) and then these results will be stored on the database.
The thing is, I need to allow user1 to only be able to see the forms we want user1 to fill out, and the same for user2,3...etc. We have the bones of the site set up, but I'm looking for a plug-in or theme or something that can allow different users to see different pages. Is there one available?
Or would any you have any idea how to go about this another way?
I have spent the best part of a days searching but I can't find a viable solution. Any help would be greatly appreciated!
Two things can be done.
Use Contact form 7 or Gravity form plugin to create different forms. Create user specific pages where you like to show forms. Paste corresponding form short-codes in the pages.
Use Role Scoper plugin to restrict users to see pages. You can set permissions for different user to see different pages.
Hope this helps you.

drupal give permission to access a content to authenticated user only

I am using a drupal 6. I need to restrict access to certain pages to my site for only the authenticated users. All these pages are having their own primary navigation parent menu, mouse hover on which it shows the sub menu to these pages. Once user clicks on it, it should show the page content if user is authenticated otherwise should show "Access Denied".
I tried to use Content Access module, though it restricts the access to the pages but it does not even show the menu link to anonymous user in menu list.
Is it possible to show menu in menu list, but on clicking on link it should show the access denied message of user is anonymous?
There are 2 ways you can go about this, the field permissions module if you just want to limit to specific fields or you can make a PHP block, call global $user within it, and if the user's role doesn't match on the node type for who you need to be, then call drupal_access_denied()
http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_access_denied/6
The block method is going to be much more efficient because you won't have to configure a billion checkboxes if you have a lot of fields and because if you make the block within a custom module, it will be exportable easily to other Drupal sites.

Restrict access to page for anonymous users in Drupal

Very simple question that i'm stuck with.
I'm making a very simple 'classifieds' website; i have a content-type of type 'classified' i'd like to give access to that content-type for registered users only; i edited the permissions so only 'authenticated' users can 'create classified' and also created a menu link to 'node/add/classified'.
The problem is that when anonymous, i don't see the 'create classified' menu link (right, because the user doesn't have the right to 'create' one) but I still want this menu item to appear and i'm redirecting to my custom 403 page that says 'hey, you have to create an account first before posting a classified'.
What's the best 'elegant' way to achieve this ?
My solution would be to create a new page (via hook_menu) at, say "classified/add". In this page, check the user's id = if it's 0, then display your friendly message about joining the site.
If they aren't 0, then append/return node_add('classified'). (Note that node_add is in node.pages.inc, so you'll want to include that when needed.)
I have actually done the same thing for a classified ad system. Creating absolute URLs as menu items works for me and is quite simple.
For example, instead of making the menu item path 'node/add/classified', set the path to 'http://example.com/node/add/classified'. When you click the menu item when logged out (as anonymous), Drupal will try to go to the create classified page, but will fail the permissions check and redirect to your custom 403 page.
Try creating a new menu item manually (Admin > Site building > Menus > Menu name > Add item), to point to the node/add/classified URL.
Update: You could try linking to /node/403?destination=node/add/classified (where node/403 is your custom 403 error page).

Resources