Support

Account

Forum Replies Created

  • I thought of that myself, but was hoping to there would be a function available. thanks.

  • On a side note… You overlooked another question I asked somewhere in this topic.

    Is it possible to β€˜disable’ the photo editor for users on the front-end ?

    Now I have the possibility to let users upload images, I prefer to have them not be able to edit the title/alt/description since I don’t use them. I generate them in a different way.

  • I understand what you mean, but for the time being I don’t see another way then to add manage_options as a cap for the role(s) in question and expand these current_user_can statements.

    All statements have been checked, double checked, triple checked and disabled.
    Nothing worked.

    in functions.php: capability for adding acf_options_page
    in acf.php: doing nothing now (empty statement), but will be a check if a user needs to get an email or not
    in admin-columns.php: unset yoast stuff
    in page.php: check if an error image should be shown or not
    in profile.php: check to see if user can ‘view’ other profiles. This one needs to be extended, so users can’t view other users’ profile (like I can).

    So nothing I see which is related to ACF’s image/media upload.

    The link you gave looks interesting but have to look into it later if it’s something for me.

  • It appears this piece of code does basically what I suggested above, but in a different way. The snippet does it by code, I did it by adding a cap through user role editor.

    In the post you linked, they filter the user upload, but this is already taken care of by ACF so I don’t need that.

    Do you see any caveats in the way I described to solve it ???

    In a private post above you received the ftp details.
    Would you have some time to d/l the template and search in the files for current_user_can and verify that these are not related to this issue ?
    It’s only 5 or so, so shouldn’t be that much work. Appreciated if you can, too bad if not.

    This so frustrates me like you won’t believe πŸ™‚

  • LOL… are we telepathically in sync or so πŸ™‚

    I just did that and wanted to ‘report’ that it does work when all capabilities are turned on… so will investigate further…

    Edit: I killed caps 1 by 1 until I got to manage_options which seems to be the trigger.

    I then looked throughout the entire template but I can’t find any indication where this would be set. I only have 5 functions which check if current_user_can and non indicate that it could be related.

    I might know a workaround, by adding the capability manage_options to this user role and then extend all if current_user_can('manage_options') queries with specific roles.

    The most important one being to redirect any user who has no business in the admin.

    It’s not ideal, I’m the first one to agree, but I don’t see any way right now… I don’t know where to look anymore.

  • I am the author, well co-author πŸ™‚ it’s a theme which is written entirely from scratch between colleagues and I.

    I deactivated almost all plugins and a ton of features in functions.php but I can’t pinpoint it yet which annoys the hell out of me, because the images are a main feature of the site.

    Since only admins have the right to upload, I tried looking for current_user_can statements but I checked all of them but no luck.

    There are no console errors, only the console.logs I built in to check if certain stuff is loaded… And no errors appear.

  • This reply has been marked as private.
  • I added the caps which weren’t added (create_posts) but this didn’t change a thing…

    I find it weird only admins can add images but other roles can’t. I looked through all my code to see if there was something related to current_user_can() but nothing.

    The basic uploader is not what I want, because that way images don’t seem to be linked to a post and some of my functions get bypassed.

    It really frustrates me, been working on this whole day and can’t find the solution (or even a hint) to why users can’t upload.

    I deactivated a whole bunch of plugins but nothing πŸ™

    Edit: just switched to twentytwelve and it does work there, so it is something theme related, since that was the only difference. I didn’t deactivate any plugins during this test.

    I tried eliminating a whole bunch of template functions but I can’t get it to work yet.

  • Sorry have another question πŸ™‚

    The image upload seems to be working for administrators. If I use a lower user role, I get an error, saying an error has occurred. But no specification what type of error.

    Only limitations I have is minimum size (dimensions) and max file size.
    I had a file type limitation but took it out for a test. Doesn’t work with/without.

    Do users need a custom capability to upload images ?
    Thought the form took care of it.

    Note: all user roles have the cap upload_files

    Edit: I tested all user roles (with the wp uploader), none works except administrator… All end in error, without specifying what the error is.

    More edit: I noticed it only occurs when using the wp uploader. I set it to basic and now the (single) photo uploader works. But the gallery still uses the wp uploader.

  • Ok, now I have the form working, it brings another question.
    I haven’t looked for it yet, but is it possible to ‘disable’ the photo editor for users on the front-end ?

    I don’t want them to change the image title/description etc.

  • You were right….
    When I changed $post_ID to a hardcoded post ID (which had images), the images showed right away on the front-end.

    I fiddled around with ob_start but I didn’t quite know how/what… So I started to retest everything from the beginning and I think there might have been an incorrect var on line 37, because I have managed to get the form up and running without the use of ob_start.

    Will need to do some more testing but first signals look good. I also need to rewrite the code, because my code is not written DRY, so I need to delete the 2nd instance of the acf_form (but that’s not perse necessary for it to work).

    PS didn’t think I could upload files here, so hence why the long json export in private and pastebin. You may delete them since we don’t need them anymore.

  • This reply has been marked as private.
  • This reply has been marked as private.
  • I removed both returns from the shortcode, but nothing changed.

    Not quite sure what you mean with by putting it into a variable.

  • This reply has been marked as private.
  • My acf_form is on a page. By adding a variable I ‘feed’ the proper post ID into the form. Like so: http://dvp.dev/edit-advertentie/?id=492
    And yes it’s on there πŸ™‚

    I use twig so I can’t place php in files, so I created a shortcode which echoes the acf_form and takes the posted variabale into account as the post_id.

    This is the shortcode code: http://pastebin.com/dDANWavf

    This is the code I use to display the form: http://pastebin.com/rFL7mEWF.
    As I said it’s Twig, but basically on line 18 it checks if the user has an id.
    If so, he’s logged in. If no id = provided in the url then no post ID is passed to the form. If an id is passed (like in the URL above), then that post values are loaded into the form. Works on all fields, except the images.

    I’ll send the JSON export in a private post after this.

  • I wasn’t sure if the admin_footer was limited to the back-end in some way, hence the question.

  • This topic was before I made a front-end form.

    I have it working on the front-end now.
    I noticed it works with acf/render_field and acf/input/admin_footer.
    Does it matter which one I use ?

  • Like many I also wanted to have conditional fields related to a taxonomy and I solved this issue with only 14 lines of code (not counting commented lines)… I think several people may benefit from this.

    I first had a simple radio button as for a custom field called sex.
    Based upon this selection some other fields came into action, such as cup size for women.

    I then decided to make a taxonomy for sex. I didn’t add an ACF field for it. Instead I added an acf/save_post action, which changes the taxonomy on post save, based on the value which was entered in the ACF field.

    So the page loads the custom field value and on save it changes the taxonomy if those values are not the same.

    Add this to functions.php

    
    function change_post_taxonomy_44582( $post_id ) {
        // bail if no ACF data
        if ( empty($_POST['acf']) ) {
            return;
        }
        // get term id from $post_id (only 1 value is allowed, so it returns 1 value only)
        $stored_sex = wp_get_post_terms($post_id, 'sd_sex');
        // get submitted value from acf form
        $posted_sex = $_POST['acf']['field_57e3ed6c92fd1'];
        // get term_id for the submitted value
        $term_id    = get_term_by( 'name', $posted_sex, 'sd_sex' );
        // if stored value is not equal to posted value, then update terms
        if ( $stored_sex != $posted_sex ) {
            wp_set_object_terms( $post_id, $term_id->term_id, 'sd_sex' );
        }
    }
    add_action('acf/save_post', 'change_post_taxonomy_44582', 20);
    
    

    Hope this helps some people.

  • Right now I’m planning to use this since it’s working πŸ˜‰ The only variable I use is a post ID, so I think I’m fairly save.

    How would you recommend to do it ?

    The only thing I can’t achieve yet is strip special characters from an ACF field.
    I can strip them from the field and insert the stripped title into post_title but back in to the ACF field gives me an empty ACF field and title.

  • I then tried to repeat something similar to ADD the post title upon first submit from the same acf field with the help of this explanation.

    After testing with exits, I noticed new_post is never the variable so it never reaches the rest of the code.

    I echoed the post_id with an exit (before line 10) and it always returned an ID, so the script returns the ID on line 10 and never passes that.

    When I commented out the return, I got 2 new posts instead of one. One did now actually have the title as I wanted it but the second one is also inserted.

    So I removed the insert and added an update to change the post title and name.

    Can you take a look at this function and see if all looks good ?

    It appears to work as expected and all, but would like to make sure it’s all on the up and up.

  • Hi Jonathan,
    Thanks for the answer.

    I know about post_title => true but I don’t like it because I prefer to have it IN the form, instead of above it.

    I don’t quite understand what you mean with remove the acf/save_post hook. The functions I mentioned are not in use right now (the file in which they reside is not included right now because I couldn’t get them to work), so is there something to remove ?

    I hooked your function into acf/save_post and it works like a charm.
    I added a bit of code myself to also update the post title simultaneously.
    This is the final working result but I need the remove/add actions here ?

  • My $post is a new TimberPost(), so I tried creating a TimberHelper, as described on the previous link.

    That gives this output for $post.
    Would you know which var could cause this issue ???

    It’s not really needed anymore, since I have found a solution but I’m still interested to know/understand it.

    Solution: I just created a simple shortcode with attributes to determine the array values. Just test this and works as expected…

    PS you don’t have to thank me on each post for ‘reaching out’ πŸ™‚

  • I assume you mean

    
    __($string, 'textdomain')
    

    instead of ‘just’ an English string ?

    when I say I echo my names in the templates, I meant of course properly prepared for translation…

Viewing 25 posts - 251 through 275 (of 291 total)