I made a simple Wordpress plugin which adds files to users but I hit errors when I try and add more than 139 files to a user.
Is there some sort of built in limits with php, wordpress or even the htaccess file that could be causing this? I say this only because there is nothing in my code to put any limits in place.
This is the bit of code which I believe submits the file upload:
//user porfile fields save
public function save_user_file_upload_fields($user_id) {
if (isset($_POST['bhuufu-user-uploads']['file_url_tmp']) && $extra_fields = array_filter($_POST['bhuufu-user-uploads']['file_url_tmp'])) {
foreach ($extra_fields as $key => $value) {
$_POST['bhuufu-user-uploads']['file_url'][] = $_POST['bhuufu-user-uploads']['file_url_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_name'][] = $_POST['bhuufu-user-uploads']['file_name_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_description'][] = $_POST['bhuufu-user-uploads']['file_description_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_id'][] = $_POST['bhuufu-user-uploads']['file_id_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_oname'][] = $_POST['bhuufu-user-uploads']['file_oname_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_mime'][] = $_POST['bhuufu-user-uploads']['file_mime_tmp'][$key];
}
}
It's all been done with post so I think there maybe an issue with this but I am not sure what. It works perfectly up to this limit.
I've done a bit of searching but Google doesn't bring up anything about any sort of array limits when coming to that specific number and I'm surprised I'm the only one who hit this problem.
You can check value of max_input_vars & max_input_nesting_level using phpinfo() function. Try to increase those value. When it is set, it limits your number of inputs (that is, fields in your forms).
Above values are configurable. Edit your php.ini or htaccess to update those values.
Like I wrote you on the original question - this is probably because you are using $POST vars , and passing the limits of max_input_vars variable in php.ini that was introduced in PHP version 5.3.9 and has the default value of 1000.
This is common problem in WP, and usually people encounter it dealing with menu items , like explained in this post I included my comment on your original question ( closed ) You can read there for further details.
Related
I am currently trying to add the username of the currently logged in FE user as a constant. I have tried the following but it does not seem to work.
Username = TSFE:fe_user|user|username
I am using this as a starting point
I would like to know how get the FE username into a constant so I can call it when ever I need for the rest of my typoscript.
This is the bit of typoscript that I am trying to get the username into, at the moment it just adds the company name which is defined as a constant else where, but I would like to add int he username also. I have tried adding the global variable for the username but no joy.
[usergroup = *]
config.tx_we_google_analytics {
_setCustomVar = 1, 'Client', '{$companyName} - {TSFE:fe_user|user|username}',2
}
[end]
Many Thanks in Advance
Bob
I wouldn't recommend using an extension to insert something as basic as a Google Analytics Snippet. Each extension slows down the system and makes it less maintainable.
I don't know what your customVar does, but you might try something like
temp.analytics = COA
temp.analytics {
10 = TEXT
10.value (
first part of GA snippet
)
20 = TEXT
20.data = TSFE:fe_user|user|username
30 = TEXT
30.value (
rest of GA Snippet
)
}
Then insert your snippet where you want, e.g. headerData.99 < temp.analyticsand you're done.
Or even try with a wrap and insertData=1.
As Artur says, if data doesn't render in .wrap, always try stdWrap.wrap - it tends to add functionality (although afaik there have been efforts to pass every wrap through stdWrap by default, but I don't think it's fully implemented).
You can use the appropriate global variable inside TypoScript setup directly, there is no need for a constant I think. The example you provided is the global variable I am talking about, which you can use in any getText context inside typoscript setup.
e.g.
temp.userName = TEXT
temp.userName.data = TSFE:fe_user|user|username
TypoScript constants allow only direct value assignment, it is not possible to assign any other "variable" to a constant IMHO.
Try this. If you are lucky it could work.
[usergroup = *]
config.tx_we_google_analytics {
_setCustomVar.cObject = TEXT
_setCustomVar.cObject.value = 1, 'Client', '{$companyName} - {TSFE:fe_user|user|username}',2
_setCustomVar.cObject.insertData = 1
}
[end]
If it doesn't, you will have to modify the plugin code to process the config value by stdWrap. Thsi code works from within the plugin controller
$configValue = $this->cObj->stdWrap('',$GLOBALS['TSFE']->tmpl->setup['config.']['tx_we_google_analytics.']['_setCustomVar.']);
or simpler (stil within the controller)
$configValue = $this->cObj->stdWrap('',$this->conf['_setCustomVar.']);
I have been looking through code and forums for hours. Does any one know how to make it so that by default the Global features drop down is set to off on the options_name_manager file so that the global features are hidden. I have a customer who doesn't need to see those options and so I want to hide it.
I have done some extensive googling and come up blank. Any help is appreciated. I have even tried hard coding the variable which changes the drop down but doesn't hide the section that it needs to!!
I admin/options_name_manager.php on line 13 in 1.3.9 (right above where the $_GET['action'] is done) do this:
$_SESSION['option_names_values_copier'] = 0;
-- updated based on changed requirements
If you want to default it to off but retain the ability to change it, do something more like this:
if (!isset($_SESSION['option_names_values_copier'])) {
$_SESSION['option_names_values_copier'] = 0;
}
Then the setting will only be made if it isn't already set.
I have a question about the optional_param function in a form in PHP (version 5.3.14)
After looking over why certain fields were not being saved in a form I have, I realised that this data...
$checkdata = optional_param('items', array(), PARAM_INT)
Only saves up to 996 places (items) from the form (they are select items and there are many)....
Is this a setting or a something I can change? or alternatively something wrong from my end?
Thanks in advance
Solution : A moodle function (platform i am working with)
Thanks Pekka
this function is a moodle function. It gets a parameter from the current page URL.
For an example url:
http://moodle.dev/course/view.php?id=2&items=4
(this is chosen totally arbitrary)
Using this code:
$checkdata = optional_param('items', array(), PARAM_INT)
Will save the "items" value (here it's 4) in $checkdata. If items does not exist in the url it will do $checkdata = array()
I have installed typo3, templavoila and mapped a template.
Everything works fine, except my content elements. They just don't appear. They did before I installed templavoila and mapped a template.
Also, when using
10 = RECORDS
10 {
tables = tt_content
source = 9
}
it does not give me any output.
even nothing with:
10 = RECORDS
10 {
tables = tt_content
source = 9
conf.tt_content = TEXT
conf.tt_content.value = TEST
}
Does anyone have a clue as to what I might be doing wrong?
You must include the css styled content static template in your TS template.
In your ts page object you need to assign it to the templavoila object.
# Default PAGE object:
page = PAGE
page.typeNum = 0
page.10 = USER
page.10.userFunc = tx_templavoila_pi1->main_page
Probably the page, where tt_content is situated is not visible to regular visitor ?
In this case, following snippet will help.
10 = RECORDS
10.tables = tt_content
10.source = 9
10.dontCheckPid = 1
Finally we got it to work. Don't know what I did wrong, but I guess I learned not to do it again.
I'll put the "solution" here since someone might find it helpful and lose more than a day over this like I did.
Solution:
copy an existing content element in list mode, pasted it on a page via page mode
This was to test if that would do anything. Guess what, everything worked again. Not only the newly copied element but also ALL other test elements created via different ways on different pages and storage folders.
Thank you all for helping and thinking along.
I am basically creating an iphone app that get's it's data from wordpress. Wordpress will serve audio and video links via a RSS feed to the iphone app. I have the feed and audio player working great but can't seem to find anything related to how to create a custom feed where I can specify pagination like start=0&items=10. A plugin would be great but I can code something up in PHP if anyone has any ideas.
I'm going to answer this question by changing the standard RSS feed of a WordPress installation to respond to limits passed by query parameters. As you say you've already got a working feed, this should hopefully give you everything else you need.
By default, the standard feeds in WordPress are limited by the setting "Syndication feeds show the most recent X items" on the Settings→Reading page, and are unpaginated, as that wouldn't generally make sense for an RSS feed. This is controlled by WordPress's WP_Query::get_posts() method, in query.php, if you're interested in taking a look at how things work internally.
However, although the feed query's limit is set to LIMIT 0, X (where X is the above setting, 10 by default) , you can override the limit by filtering the query in the right place.
For example, the filter post_limits will filter the LIMIT clause of the query between the point it's set up by the default code for feeds and the time it's run. So, the following code in a plugin -- or even in your theme's functions.php -- will completely unlimit the items returned in your RSS feeds:
function custom_rss_limits($limits) {
if (is_feed()) {
// If this is a feed, drop the LIMIT clause completely
return "";
} else {
// It's not a feed; leave the normal LIMIT in place.
return $limits;
}
}
add_filter('post_limits', 'custom_rss_limits');
(At this point I should mention the obvious security implications -- if you've got 20,000 posts on your blog, you'll cause yourself a lot of server load and bandwidth if if lots of people start grabbing your feed, and you send out all 20,000 items to everyone. Therefore, bear in mind that whatever you end up doing, you may still want to enforce some hard limits, in case someone figures out your feed endpoint can be asked for everything, say by analysing traffic from your iPhone app.)
Now all we've got to do is to respond to query parameters. First of all, we register your two query parameters with WordPress:
function rss_limit_queryvars( $qv ) {
$qv[] = 'start';
$qv[] = 'items';
return $qv;
}
add_filter('query_vars', 'rss_limit_queryvars' );
That allows us to pass in the start and items variables you're suggesting for your URL parameters.
All we have to do then is to adjust our original LIMIT changing function to respond to them:
function custom_rss_limits($limits) {
if (is_feed()) {
global $wp_query;
if (isset($wp_query->query_vars['start']) &&
isset($wp_query->query_vars['items'])) {
// We're a feed, and we got pagination parameters. Override our
// standard limit.
// First convert to ints in case anyone's put something hinky
// in the query string.
$start = intval($wp_query->query_vars['start']);
$items = intval($wp_query->query_vars['items']);
$limits = "LIMIT $start, $items";
} else {
// We weren't passed pagination parameters, so just
// leave the default limits alone.
}
}
return $limits;
}
add_filter('post_limits', 'custom_rss_limits');
And there you go. Throw those last two blocks of code at WordPress, and you can now use a URL like this on any of your existing feeds:
http://example.com/feed/?start=30&items=25
For this example, you'll get the normal RSS feed, but with 25 items starting from item number 30.
...and if you don't pass the query parameters, everything will work like normal.