Wordpress Plugin in error for user Pro - php

Hey can anyone explain to me why I get this error when I try to save the registration form.
Fatal error: Cannot unset string offsets in /home/wolf/public_html/wp-content/plugins/userpro/admin/admin-functions.php on line 252
Here is the line in question for the php.
/** List all groups **/
function userpro_admin_list_groups(){
global $userpro;
$output = null;
$groups = $userpro->groups;
unset($groups['register']);
unset($groups['edit']);
unset($groups['view']);
unset($groups['login']);
unset($groups['social']);
$array = array(
'register' => __('Registration Fields','userpro'),
'edit' => __('Edit Profile Fields','userpro'),
'login' => __('Login Fields','userpro'),
'social' => __('Social Fields','userpro')
);
IF anyone can shed some liht on this that would be great as far as i see theres nothing written wrong, and even the plugin maker is scrating his head on this....
the config for the php is 5.4
And the Apache is 2.4
Mysql is running 5.6

Related

I keep getting a “Call to undefined function..” error displaying

I am new to PHP programming and I am trying to teach myself WordPress theme development for fun and I am using PhpStorm as my IDE.
I am trying to better understand the inner-workings of WordPress and I am running into a roadblock on something.
I have a sandbox plugin that I created to use to play around with WordPress.
In my “wp-content/plugins/sandbox/sandbox.php” file, I am just running basic PHP code to help me get used to the language as it relates to WordPress.
Also, I installed both Kint and Whoops using Composer to help with debugging.
Now that I got that out of the way, here is what I am doing:
Code #1
namespace MyDevPlayground\Sandbox;
add_action( 'loop_start', __NAMESPACE__ . '\process_the_string' );
function process_the_string() {
$current_user = wp_get_current_user();
$data_packet = array(
'id' => $current_user->ID,
'email' => $current_user->user_email,
'name' => array(
'first_name' => $current_user->user_firstname,
'last_name' => $current_user->user_lastname,
),
);
render_user_message( $data_packet );
}
function render_user_message( array $current_user ) {
$user_id = $current_user['id'];
d( "Welcome {$current_user['name']['first_name']}, your user id is { {$user_id} }." );
ddd( "Welcome {$current_user['name']['first_name']}, your user id is {$user_id}." );
}
When I run Code #1 above everything is fine and Kint displays the values just fine.
Now for the problem I am having that I don’t understand about WordPress:
Code #2
namespace MyDevPlayground\Sandbox;
add_action( 'loop_start', __NAMESPACE__ . '\check_logged_in_user' );
function check_logged_in_user(){
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
d('Not logged in');
} else {
ddd('Logged in');
}
}
check_logged_in_user();
When I run Code #2 above, Whoops reports the following error:
Call to undefined function MyDevPlaygroundSandbox\wp_get_current_user
For some reason when I run Code #1, the wp_get_current_user() function loads just fine, but not with Code #2.
Can someone help me understand why this is in laymen’s terms if possible?
What is the difference between Code #1 and Code #2?
How come the wp_get_current_user() function is not loading in Code #2, but it is in Code #1?
Thank you for your help.
when you use "add_action" command you can not use function name for calling that action,
you need to use the call command like this :
do_action("check_logged_in_user");
more information : https://developer.wordpress.org/reference/functions/add_action/

Clear TotalCache cache automatically from code WordPress

I have several WordPress sites hosted in my server, and some of them have the W3 Total Cache plugin installed. Right now I flush the cache for each site manually, but I want to do it programatically and all together.
I'm trying to write a PHP script that will do this. I was looking at the code used by the "Clean Cache All" option for this plugin in the dashboard, and is this piece here:
if ( $modules->plugin_is_enabled() ) {
$menu_items['10010.generic'] = array(
'id' => 'w3tc_flush_all',
'parent' => 'w3tc',
'title' => __( 'Purge All Caches', 'w3-total-cache' ),
'href' => wp_nonce_url( network_admin_url(
'admin.php?page=w3tc_dashboard&w3tc_flush_all' ),
'w3tc' ));
So I'm guessing there are 2 ways to do what I need:
1- Make a web request, but that would probably require authentication.
2- Instance the class and use the method w3tc_flush_all();
This is what I have thus far:
function clean_cache($web)
{
global $path;
$path2 = $path.$web["directory"]."/httpdocs/wp-content/plugins/w3-total-cache/";
if(file_exists($path2)) //Tienen TotalCache instalado
{
require_once $path.'w3-total-cache-api.php';
//if(class_exists("w3-total-cache-api.php"))
//{
$plugin_totalcache = & w3_instance("w3-total-cache-api.php");
//if(function_exists('w3tc_dbcache_flush'))
$plugin_totalcache->w3tc_fush_all();
//}
}
}
Any help will be much appreciated.

Magento Fault Code 1 No other info available

I am trying to use the Magento API to UPDATE a product. I am getting error code #1 with the following message:<b>Fatal error</b>: Uncaught SoapFault exception: [1] Internal Error. Please see log for details.
Below is my PHP that calls the service and should update three attributes. The Magento api documentation leaves a lot to the imagination so I am stuck
$ItemNmbr = $itemData->Item->ItemNmbr;
$ItemDesc = $itemData->Item->ItemDesc;
$UnitPrce = $itemData->Item->UnitPrce;
$client = new SoapClient('http://website.com/store/api/?wsdl');
$session = $client->login('apiname', 'apipassword');
$result = $client->call($session, 'catalog_product.update', array(168, array(
'description' => $ItemDesc,
'price' => $UnitPrce,
'weight' => $Weight
)));
var_dump ($result);
I am statically setting the ProductID above for now. Any information that will help me understand what I am doing wrong would be much appreciated.

MongoDB running command in lithium

I'm trying to run a full text search against some data that is stored in mongoDb using Lithium.
Here is how I am trying to do it in my controller:
$mongodb = Connections::get('default')->connection;
$results = Page::connection()->connection->command(array("text" => "Page", 'search' => "term" ));
I've also tried:
$results = Page::connection()->connection->command(array("text" => "Page", 'search' => "term" ));
However, both of these return: Fatal error: Call to a member function command() on a non-object
What am I doing wrong?
EDIT:
I should add that a simple query on Page is working just fine. For instance:
$results = Page::find('all');
Does return an array with all of the documents in the pages collection like I would expect it to.
UPDATE 2:
I was running all of this from WAMP server. I tried today running it from a linux server, but still got the same exact error. I am really stumped by this and could use some help. Anyone have any ideas?
here is the Page model as it sits now:
<?php
namespace app\models;
use lithium\data\Connections; //added during debugging
use lithium\data\source\MongoDb; //added during debuging
class Page extends \lithium\data\Model {
}
?>
Here is my connection:
Connections::add('default', array(
'type' => 'MongoDb',
'host' => '192.168.48.128',
'database' => 'my_collection'
));
I'm doing it this way:
$plugins = Plugins::connection()->connection->command([
'text' => 'plugins',
'search' => $this->request->query['q']
]);
return compact('plugins');
so I'd recommend checking your configuration - is your model returning other data normally? Is the connection configuration correct?
Got help to figure it out... posting here for others to reference.
proper way of calling it is:
$conn = Model::connection();
$db = $conn->selectDB('db');
$result = $db->command(array(...
Works perfectly when done this way.

Cannot declare phptemplate_settings() - Drupal error when trying to configure template

There are two templates, whitejazz and a modified whitejazz (forumwhitejazz) - both are enabled.
I'm trying to configure the modified whitejazz, and I am getting this error - what does it mean?
Should I post anything else to help deduce this? I'm utterly stumped - my googling of this issue has not given me any solid leads.
This is in Drupal 6.25
Fatal error: Cannot redeclare phptemplate_settings() (previously declared in /home/domain/public_html/drupal-6.25/sites/all/themes/whitejazz/theme-settings.php:3) in /home/domain/public_html/drupal-6.25/sites/all/themes/forumwhitejazz/theme-settings.php on line 135
The problem is that function phptemplate_settings() was defined twice. This goes to fatal php error.
What I suggest to do is:
Create file theme-setting.php in root folder of forumwhitejazz template
There define function as in example and put there code settings.
Example:
function forumwhitejazz_settings($saved_settings) {
$form = array();
$form['forumwhitejazz_example'] = array(
'#type' => 'checkbox',
'#title' => t('Use this sample setting'),
'#default_value' => $saved_settings['forumwhitejazz_example'],
'#description' => t("This option doesn't do anything; it's just an example."),
);
return $form;
}

Categories