gpspake
Forum Replies Created
-
WPUF doesn’t do this automatically.
The function my_login_redirect() above says ‘If the user is an admin, redirect them to ‘https://someurl.com/wp-admin/’, otherwise, redirect them to return ‘https://someurl.com/contribute/.
Then it gets hooked in to the wordpress function ‘login_redirect()’you have to add that code above in your theme’s functions.php file and replace ‘https://someurl.com/wp-admin/’ and ‘https://someurl.com/contribute/’ to whatever page you want people to get redirected to.
Forum: Plugins
In reply to: get all of the terms that exist in all taxonomiesOk, so I don’t know what I was doing wrong because I tried this before and couldn’t get it to work, but I ended up using array_values() after a couple of people recommended it in another thread.
I finally ended up writing it like this:
$mytermobjects = get_terms( array_values((get_taxonomies('','names'))) , $args );
Yeah, that certainly was not a final solution. This is one of the main features that encouraged me to install the development fork, which fixes this properly.
Cool man! I’m zoned in to another project today but I can’t wait to check this out. Thanks.
Well man, if you’re still interested, I think I just figured it out, at least for what I needed. It was surprisingly simple and I don’t see how it could require very much additional code to fully integrate in to the plugin.
I only needed to exclude a couple of categories from the list so in wpuf-functions.php, inside of WPUF_Walker_Category_Checklist I added the following:
class WPUF_Walker_Category_Checklist extends Walker { ... function start_el( &$output, $category, $depth, $args ) { if ($category->term_id == 1 || $category->term_id == 31 || $category->term_id == 37 ) { // If the term id is 1, 31, or 37 return; // Skip it }
That’s it for me.
Now, in your case, you could wrap it up in a conditional that checks the user’s role and, to really do it right you could replace the conditions in the if statement with an array or something and add some options to the plugin settings interface in the dashboard.Well, I haven’t looked in to it too much but subscribers are already restricted from deleting images that they didn’t upload so I’m guessing there’s got to be some way to filter out those pics.
My logic is, if I can restrict users from deleting pics uploaded by other users from the library, I should be able to prevent them from seeing those pics in the library.Thanks prof,
Works great. There’s still some interface I need to do; I don’t want users to be able to see other peoples pictures in the library and I don’t want to let them delete images from posts that have been published (This would probably involve ‘the attachments to link to the new or edited post’.
This should make it a lot easier though. I’ll let you know if I make any progress.
Hey setnaps,
You ever get anywhere with this?
It’s a tricky issue. I could probably think of at least 5 more args that should be included in wp_terms_checklist(), this being one of them.There should be an option to pass an array of categories to exclude as well as a boolean ‘$showuncategorized’ arg.
Unfortunately, since there aren’t, I’m finding that it’s kind of a pain to pull out any cats.
I’ll probably end up hardcoding this. If you ever made any progress, I’d appreciate any suggestions. In the meantime, I’m going to keep trying to figure out how to do this without modifying the walker.Prof,
This makes a lot of sense; Thanks for taking the time to type all of that out.
Now that we know the differences between 3.5 and previous versions, I have no problem with ignoring older versions and focusing solely on 3.5.That being said, you mentioned that the media_view_settings filter would probably be the easiest solution here. (Apologies in advance for not knowing what I’m talking about)
So just thinking out loud, I guess we would want to do something like:
if (add-post-page or edit-post-page){ //Only do this on these 2 pages add_filter ('replace_the_id', 'media_view_settings') function replace_the_id() { array( 'id' = the wpuf id, 'nonce' => wp_create_nonce( 'update-post_' . wpuf nonce ), } }
Or should I be trying to do this with jquery like the previous approach?
Ok guys, here’s what I’ve got. This isn’t finished and there might be some bugs i haven’t run in to yet; I’m going to be kicking it some to see if I can break it but it seems to be a viable solution. Right now anything is better than giving subscribers page editing capabilities.
First of all, I was using this tutorial. I had to the code some, probably because things are a little different in wpuf but it seems to be working.
……………….
***NOTE IMPORTANT!!! THIS IS NOT USABLE YET. TWO THINGS.
1. The post ID
Essentially what we’re doing is creating our own media uploader frame and replacing the wpModel settings post id (Whatever that is) with a different one, in this case it should be the wpuf id which you can get by usingdocument.getElementsByName('post_id')[0].value;
Unfortunately I’m still working on this because if I setdocument.getElementsByName('post_id')[0].value;
to a variable, everything stops working.2. Add Post page.
I have been working on this on the edit post page.So Once I get the post id thing working I’ll need to move over to add-post and get it working there. Who knows, there might not be any problem. We’ll see.
……………….Anyway here it is.
Create a .js file; in my case, I named it uploader_custom.js and put it in a folder called js in my child theme directory.Then you need to call it in functions.php. This needs to be cleaned up and modified to only load on the add post and edit pages.
function mytheme_register_scripts() { wp_register_script( 'theme-custom', '/wp-content/themes/mythemedirectory/js/uploader_custom.js', array('jquery'), '1.0.0', true ); } add_action('init', 'mytheme_register_scripts'); function mytheme_enqueue_scripts(){ wp_enqueue_script('theme-custom'); //custom.js } add_action('wp_print_scripts', 'mytheme_enqueue_scripts');
Here’s the js that goes in uploader_custom.js
// Uploading files var file_frame; //jQuery('.upload_image_button').live('click', function( event ){ jQuery('.insert-media').live('click', function( event ){ event.preventDefault(); var wp_media_post_id = wp.media.model.settings.post.id ; var set_to_post_id = 1197; // Set this // If the media frame already exists, reopen it. if ( file_frame ) { // Set the post ID to what we want file_frame.uploader.uploader.param( 'post_id', set_to_post_id ); // Open frame file_frame.open(); return; }else { // Set the wp.media post id so the uploader grabs the ID we want when initialised wp.media.model.settings.post.id = set_to_post_id; } //alert (wp.media.model.settings.post.id); // Create the media frame. file_frame = wp.media.frames.file_frame = wp.media({ title: jQuery( this ).data( 'uploader_title' ), button: { text: jQuery( this ).data( 'uploader_button_text' ), }, multiple: false // Set to true to allow multiple files to be selected }); // When an image is selected, run a callback. file_frame.on( 'select', function() { // We set multiple to false so only get one image from the uploader attachment = file_frame.state().get('selection').first().toJSON(); // Do something with attachment.id and/or attachment.url here }); // Finally, open the modal file_frame.open(); });
This is sort of a learning experience for me. If anyone has anyone has any input, I would greatly appreciate it. I’ll be updating this with any new developments.
Prof & Jong, I think I got it working with some jquery. I’m going to make absolutely sure before I post the solution. It might need some cleaning up but I successfully inserted an image into a post as a subscriber. I’ll let you know soon.
Well, the error message is the same one I’m getting. As I mentioned above you’ll notice that if you use the user role editor plugin and give users the capabilities ‘edit_pages, edit_others_pages and edit_published_pages. The error will go away and users can insert pictures directly in to the post. The problem is, they can now change the url to include any page ID and use their new capabilities to edit any page on the site. Obviously, this isn’t an option.
So, the reason the error message shows up is because the media uploader is looking at the page post-id and checking page capabilities. It should be looking at the wpuf post post-id and checking post capabilities.
I’m going to be working on this today. I’ve managed to grab both id’s with jquery and I’m going to try to replace the page id with the post id. We’ll see what happens.
Forum: Themes and Templates
In reply to: Child theme activated but stylesheet link not in sourceThose aren’t really necessary and adding them has no effect but I went ahead and added them anyway. The problem I’m having is that my stylesheet is not being loaded in to the page at all.
For the record, I’m using this in a twenty twelve child theme and it’s working fine.
/* Theme Name: GS Theme URI: georgespake.com Description: child theme Author: George Author URI: georgespake.com Template: twentytwelve Version: 1 . General comments/License Statement if any. . */ @import url(../twentytwelve/style.css);
Yeah, I’m pretty excited about it. The overhaul going to be pretty awesome and worth paying for.
I didn’t really accomplish much with the multiple forms functionality; the way Tareq is handling it is super clean and integrates in to WordPress perfectly so anything I’ve done there can’t even come close to comparing. The taxonomies check-box addition was useful but, again, he’ll be adding that functionality to the pro version much more professionally. The only suggestions I had were an option for custom post type submission and your changes that allow wp-default options for editing and deleting posts from the dashboard. Other than that, I can’t find anything I don’t like about the new one.
WPUF is a big deal and I think the pro version will compete heavily with Gravity Forms.
Personally, I’m a little bummed that I won’t be able to use any paid version on the site I’m working on because of Contract/Legal issues that the organization I work for has with GPL. I’ll probably just buy it for my self to support it since it’s been so useful.Here’s what I did. It checks if the user is an admin or an author and, if they are, they get redirected to the dashboard. Otherwise, they get redirected to the a ‘contribute’ page. This should be added to your themes functions.php file. You should be able to modify it fairly easily to do what you want.
/** Login Redirect **/ add_filter("login_redirect", "my_login_redirect", 10, 3); function my_login_redirect( $redirect_to, $request, $user ){ //is there a user to check? if( is_array( $user->roles ) ) { //check for admins if( in_array( "administrator", $user->roles ) || in_array( "editor", $user->roles ) || in_array( "author", $user->roles ) ) { // redirect them to the default place return 'https://someurl.com/wp-admin/'; } else { return 'https://someurl.com/contribute/'; } } }