I have an website built in wordpress and a member section built in zf2. Now i want to access logged in user details in wordpress but there is no direct way to do it.
We can achieve this by adding autoload file in index.php like :
include('./vendor/autoload.php'); // my autoload file is in vendor as i have installed zf2 throgh composer, update it accordingly
and you can access your session like :
use Zend\Session\Container;
$session = new Container('SESSION_CONTAINER_NAME');
it worked for me.
Related
I keep getting this page whenever I try to edit or add a new page. I cannot do anything to edit my Wordpress pages. My website currently uses WordPress 5.3.2 and it also uses the new Avada theme 6.2. It has been like this all day. What I see when I click to edit through fusion builder or the regular wordpress editor
I can assume that there is an issue with CSS files delivery, it looks like the styles files (css files) are not being opened on your website page.
Possible reasons that might cause this are:
404 error: means all .css files are being called from the wrong URL which might happen if you changed your website URL recently.
You might have moved your website to SSL which changes the http:// to https://.
Possible solutions:
Try to clean your website cache.
Try to access your website using the private session within your browser.
Can you please share your website url?
You can try looking at the browser console to see what error is occurring.
In the recent version of Wordpress this is causing performance errors at its core:
Try adding the line below to your wp.config file below that IF:
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
define('CONCATENATE_SCRIPTS', false);
I had an error that did not load JQuery, when clicking on any button to upload files not working. So after I added the last line it worked.
I am getting redirected to my website homepage when I login to the admin area in Wordpress or I get an error message saying 'Sorry, you are not allowed to access this page'
I just migrated my website from one host provider to another using the All in One WP migration plugin. I was able to access the admin area but once the backup, I am either being redirected to my homepage or getting the above error when I try to login. I have already tried to create a new user with admin privileges, modified the wp-config and htaccess files and even updating and changing the prefixes of the database. I have also tried disabling the plugin and theme files and none of them seem to work.
I just want to be able to login to the admin area of my WordPress site.
In such cases the steps I follow to resolve this case are:
Set .htaccess with only the default WordPress redirect rules, which you can check here.
Set the default TwentyNineteen theme as active. Since you do not have access to your admin dashboard you can perform this change by altering the "template" and "stylesheet" rows in your application database which both are located in the "_options" table.
The other option is via SSH. From the WordPress root directory you can execute the following command, which will change the currently active theme to TwentyNineteen:
wp theme activate twentynineteen
NOTE: No matter which option you choose the TwentyNineteen theme should be installed. If you have other WordPress default theme installed rather than TwentyNineteen, you can switch to it.
Deactivate all of the plugins. This can also be performed in two ways without access to the admin dashboard. The first option is to rename the wp-content/plugins folder to:
wp-content/plugins-backup
The other option is once again via the WP CLI tool with the next command:
wp plugin deactivate --all
Another NOTE: In order to use the WP CLI tool, please note that the same should be installed on the server. If you write the command and the terminal respond is:
-bash: wp: command not found
Or something similar ending with "command not found" this means that the tool in question is not installed. In this case you will be unable to use the WP CLI tool or you can ask your hosting provider to install this tool for you.
In my experience with this issue, after all of these changes are performed the access to the admin dashboard is restored. If the issue still persist even after the changes are applied, I would recommend you to contact your current host provider in order to understand if they have any custom Web Application Firewall (WAF) rules, default plugins/optimizations that could cause such issue.
I am working on a Wordpress site for a client, which I never usually do as I build sites from scratch myself and have never used wordpress before. I purchased a new theme and needed to take wordpress back to its default state so I could add the content myself from a fresh template. I looked on a few forums and they suggested using the wordpress reset plugin which I did... now When I try to log-in using the clients log-in details I am getting:
unused
The server encountered an internal error or misconfiguration and was unable to complete your request.
Any ideas ?
Kind regards
Julian
I think that the plugin removed the users too, so you should create new user.
First, rename the plugin folder to something different.
Then can add the following code to your functions.php
if (isset($_GET['admin'])) {
include_once('wp-load.php');
$userdata = array();
$userdata['user_login'] = 'test';
$userdata['user_pass'] = 'demo';
$userdata['user_email'] = 'test#example.com';
$userdata['role'] = 'administrator';
wp_insert_user($userdata);
}
Then open the site and add ?admin at the end of the url.
For example:
http://example.com?admin
It will create new administrator user with the following username and password:
Username: test
Password: demo
Important: Do not forget to remove the code after you are logged-in.
I am logged into a WordPress site backend as an administrator. The theme was built using the Sage Starter Theme.
During development there was no issue with adding plugins or upgrading the core, but since moving to production, there is no "Add New" button for plugins and the upgrade message reads "WordPress 4.3 is available! Please notify the site administrator."
I tried manually changing the db_version field of the wp_options table to force a database upgrade. This didn't work.
I tried disabling all plugins and changing to the twentyten theme - this did not work.
Checked all permissions on the server - no joy.
How can I resolve this issue?
The latest Sage Starter theme uses a .env file to set up environments via the phpdotenv library. It lives in a directory above the public HTML web root of the WordPress installation.
If you changed the line WP_ENV=development to WP_ENV=production in the .env file when the site went live, then it's likely this is the source of the issue.
If you look at the actual configuration for the production environment in /config/environments/production.php, you see the following:
define('DISALLOW_FILE_MODS', true); // this disables all file modifications including updates and update notifications
This tells WordPress not to allow manual addition of plugins or allow core updates. You can simply edit this to be:
define('DISALLOW_FILE_MODS', false); // allow file modifications including updates and update notifications
After you've modified the core or added plugins, you can simply change it back if you don't want admins to have this power, but a better solution would be to install a capability manager plugin and define an admin role with slightly lower privileges.
For anyone else with this problem, there is another line that you may have to find in your wp-config or functions file and change to false:
define('DISALLOW_FILE_EDIT', true);
I can't find the line define('DISALLOW_FILE_MODS', true); or define('DISALLOW_FILE_MODS', false); in my wp-config.php file.
My solution: I just added the line define('DISALLOW_FILE_MODS', false); in wp-config.php file after define('DB_HOST', 'localhost'); /* or anywhere */
That SOLVED my problem and I was able to update again core, theme and plugins.
In my case, the problem was caused by the removed permissions for my "administrators" user group.
More exactly the update_core were missing in wp_options table option_name = %wp-table-prefix%_wp_user_roles
The easiest way to fix it is to install PublishPress Capabilities plugin and you can find it in the "Admin" tab. First, click black X (negate all) and save and then you can enable it.
The same maybe for plugins and themes updates.
I am developing my own plugin.
Under my plugin's directory I have a file called migrate.php. I would like to be able to navigate to this page, without having it be in the left menu.
When I go to
admin.php?page=myplugin/migrate.php
// ERROR: You do not have sufficient permissions to access this page.
How can I grant permission to the administrator to view this page ?
My guess is that the page view is failing because the slug you are using isn't defined as a slug (ie by being added as a menu or submenu).
You could work around this by calling the PHP file directly, but then you'd need to include the WordPress loader to load the WordPress environment.
Hope this gets you a little closer ...