jaytango
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: REST request works with PAW but not from a browser callThanks @bcworkz!!! It was the missing nonce. I added the beforeSend: param with the proper nonce and it worked. I didn’t need the Authorization: header anymore.
Forum: Developing with WordPress
In reply to: REST request works with PAW but not from a browser callI checked out the $currentuser value from inside current_user_can():
When run through PAW:
WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
[user_login] => admin
[user_pass] => -redacted-
[user_nicename] => admin
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2017-03-08 20:15:48
[user_activation_key] =>
[user_status] => 0
[display_name] => admin
)
[ID] => 1
[caps] => Array
(
[administrator] => 1
)
………….And when run through the browser call:
WP_User Object
(
[data] => stdClass Object
(
)
[ID] => 0
[caps] => Array
(
)
[cap_key] =>
[roles] => Array
(
)
[allcaps] => Array
(
)
[filter] =>
)So it looks like somehow, the user is not being properly set through the browser call.
Sorry about the broken link above guys. I forgot to convert the spaces to underscores. Go ahead and try it again. It should work now.
Here’s the ugly hack guys.
https://www.wazuru.com/iMasters_WP_Files_to_Users_hack.zip
Let me know if you need any help. In the meantime, I’ll keep working on writing it into one single plugin.
Here’s what I ended up doing… Once I had the admin portion working:
1)I created a custom function getMyFiles() which checks the logged in user’s ID against the plugin’s table in the database to see if their are any files there for him. It displays the results as a simple Filename | Filesize | Date Uploaded table. I placed this function in my theme folder’s functions.php file.
2) Created a page template which calls that function right after it calls the_content();
3) Next, created a page called My Files. I assigned the aforementioned page template to this file in the “Page Attributes” drop-down on the right of the Edit Page.
4)Finally, created a file “download.php” and placed it in my theme’s folder. This file basically gets a file ID as a $_GET variable from the My Files page and references the DB to retrieve the corresponding filename. Then using headers, it prompts the user to dowloand the file instead of just opening the file in the browser. This is the ugliest part of the process because it runs completely out of the wordpress scope. It opens it’s own mysql_connect and mysql_select_db by referencing the wp-config.php
So basically, when the user logs in and then clicks on the link to the page “My Files”, the page loads using the custom template php file which in turn calls the getMyFile() function which makes a list of files. Finally, when the user clicks on one of the files, it sends the file ID value to download.php which gets the filename from the DB and prompts the user to download it.
I’m trying to learn how to incorporate all of this into one plugin. If I succeed I’ll let you guys know.
Forum: Requests and Feedback
In reply to: Can't log in to Plugin developer centerYep… waiting overnight fixed it for me.
LOL, I too have been scratching my head about this. It seems that only admins can use the tool, and only in the backend at that. So, until I find a better plugin, I’m gonna just write a function to plug into a front-end page template that basically displays the logged-in user’s files. So basically the process would be:
-Admin uploads file and assigns them to users via the backend.
-Users who log into the front end have access to a page “My Files” or whatever you want to call it.
-In that page’s template there will be a function that queries the plugin’s database and displays any files that that particular user has access too.
I know, a lot of customizing, but until now, aside from coding something from scratch, this is the closest I’ve gotten to having a admin-to-user file sharing utility. Oh well. Hopefully something better will show up. Hey, if you find a better tool before i do, let me know. Merci.
I believe it has to do with this:
https://ilikewordpress.com/357/you-do-not-have-sufficient-permissions-to-access-this-page/In the meantime, I plugged in this dirty bit of code to get me around until I figure out the proper fix. In the main file ‘imasters-wp-files-to-users.php’ change line 66….
from:
if ( function_exists(‘add_menu_page’) ):to:
if ( function_exists(‘add_menu_page’) && $_GET[‘page’]!=’imasters-wp-files-to-users/imasters-wp-files-to-users-manager.php’):This basically forces the dashboard to only show the main menu button ON the main view and not when viewing the manager.
Same here. Can’t figure out what’s wrong. Using WP 3.0