Is there build-in Twig way to detect user agent and user IP if website is powered by Drupal 8.x ?
Something like app.request.headers.get('User-Agent')
I mean without adding custom Twig function on PHP
You can try using Browser detect module:
https://www.drupal.org/project/browser_detect
Related
is there a way to send Symfony’s data from its action to Wordpress page?
For example Symfony’s action returns an array and in a Wordpress page I could iterate it?
Wordpress use template that are basic php file.
So you can make request to any rest api you want you using php. You can use your symfony rest api if you want.
Simply go in wordpress create pages and create template that will make your request to Symfony and display what you need.
It's really not recommanded but for a special case it could be possible.
You maybe should take the time to simply move your data in the wordpress DB.
I've set up af headless WP with a ReactJS frontend. My idea is to use the WP backend to store and manage content that users create. I want people to be able to sign up and login to my site, and create their own content. But my problem is, that I need a guide/tutorial how to do is. Should I use the JWT authentication plugin and how do I create users (does not have to be WP users)?
Any ideas?
Thanks Kasper
First you must create WordPress users as the WordPress code checks the capabilities of the current user to allow write access to its data. WordPress supports a REST API that allows front end JavaScript to access its data. It by default uses cookie authentication to control access. However, there are actions/filters so you can implement your own authentication. If you use the default cookie authentication then you can use the WordPress login facilities to handle authentication. The supported JavaScript client is a Backbone client. I don't know if that will work well with ReactJS (I don't know ReactJS) so you may need to some work with the front-end client side.
Incidentally, the WordPress Calypso project uses a ReactJS frontend to access the WordPress backend. I don't know this project so I don't have an opinion. My feeling is that WordPress decided on Backbone before ReactJS became well known but ReactJS is actually much better so they have the Calypso project. You can read that code to get ideas.
Currently I am developing a site in Opencart. For the blog, I am using Wordpress but my client does not want two different login sections for opencart and wordpress. Is it possible to redirect a user from the admin of wordpress to OpenCart and vice versa using a link without them having to enter a password each time?
Please advise. Your valuable suggestion will help me to sort out this problem.
This is possible by adding a simple plugin, which defines the needed (pluggable) login functions.
http://codex.wordpress.org/Pluggable_Functions
Basically, rather than logging into WP directly, you'd write the pluggable functions that authenticates the user using OpenCart's details. (Note that hooks allow you to make the login form redirect straight to the latter, too.)
Look for an existing plugin or module that does this. It would be surprising if none exist already.
Used user-profile.tpl.php to customize user profile page.
Need to use a custom template when accessing urls like 'user/3/photo' or 'user/5/photo'.
How to use multiple user profile templates based on path / url in Drupal 7? What name should I use for the template?
I'm not sure what module you're using to generate the 'user/X/photo' pages, so it's difficult to tell you exactly what template file to use. However, when in doubt about how to theme something in Drupal, install the Theme Developer module. It will allow you to see what theme file or function is currently outputting a specific page or area of the page, as well as what files or functions can be used to override it. See the screencast for more detailed information.
In our application, we would like to make a link to an online help site built using Drupal.
The problem is that this site is password protected. We would like to put the username and password in the url, so that the login is automatically made when the user clicks on the link in our application.
Is it possible and how ?
Well, doing exactly what you want (I think), can be done using the Autologin module for drupal (http://drupal.org/project/autologin), however, it is seriously not recommended for use, since it obviously means people's usernames and passwords are visible in the url, plus in any access logs. The project has therefore been discontinued, not even sure if it would work in the latest version of drupal.
Unfortunately, since drupal's form generation engine has XSS protection, it prevents you posting directly to the login page and hoping for the best.
There are a number of existing Single Sign On (SSO) solutions out there for drupal, although most of them integrate with another existing CMS or similar.
The final option is to roll your own authentication module, which somehow allows you to do this, but it's been a while since I wrote one, so take a look at the existing authentication methods drupal has for ideas.
The current replacement for Autologin is the latest version of Securesite, which is likely what you really want.
External site login
Case on same server and try from any store on same path
like /store
define('DRUPAL_ROOT','D:/wamp/www/drupal');
require_once '../includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
//change this line and put your username and password instead of 'admin' and 'password'
$account = user_authenticate('krishana', 'hiddens');
$user = user_load($account, TRUE);
drupal_session_regenerate();