Showing uploaded photos on user profile
-
I have several users/authors that upload photos to site. Each of them has profile page and i want for each author to display photos he/she uploaded to site.
Can this bi done?
-
Thanks for your question. You can add an
[mla_gallery]
shortcode to the profile page to display their photos. The Settings/Media Library Assistant Documentation tab gives the details:Author, Author Name
You can query by author’s id or “Username”, the value used to log in to the site. In the database this is the “user_nicename” column (not the “display_name” column). For example, if you log in as “john” and your id is 2 you can code:
[mla_gallery author=2]
[mla_gallery author_name='john']
Multiple author ID values are allowed, but only one author name value can be entered.
I am marking this topic resolved, but please update it if you have problems or further questions regarding the above solution. Thanks for your interest in the plugin.
I found that in documentation, but what I need is to set template so it gathers author form current page.
I need it like QueryLoop does, it takes author ID from the page and collects posts made by that author.
Thanks for clarifying your goal. In the “Gallery-specific Substitution Parameters” section of the Documentation you will find several page/post values you can add to your shortcode parameters. For your application, try something like:
[mla_gallery author="{+page_author+}"]
Thanks, that works.
I have problem with this. When set this up and tested I had only two users and it worked with them. Now i added more users and for them it does not work. Shortcode displays all photos regardless of user. Like there is no user filter.
Strangely, for the first two users it works normally – shows only photos authored by that users.
I checked everything I could think off. All users are set in the same way. The only difference is that those two first users where short code works are administrators, others are subscribers. But I tested, it changed one of the users to Administrator, and it did not change a thing. His profile still shows all photos, not only his.
What could I look for?Thanks for your report. On my system, subscribers do not have the capability to author posts/pages, so the
{+page_author+}
parameter can’t return their ID. Subscribers do not have image upload capability, either, so they can’t have photos with their ID as the author. Changing their role after the post/page is created will not have any effect.You can try adding
mla_debug=true
to your shortcode to see what it is doing. This will write lots of ugly debug information to the browser output, so use it sparingly. You can addmla_debug=log
to write the information to your site’s error log file, then use the Settings/Media Library Assistant Debug tab to view the log. You will see entries like this:679?mla_debug attributes?= array ( 'author' => '2', 'mla_debug' => 'true', 'mla_page_parameter' => 'mla_paginate_current', )
Make sure the author value is what you expect. If you post your complete shortcode I can try to duplicate it on my system. Any additional details you can provide will be helpful, thanks.
Sorry, my bad, other users are Contributors, not Subscribers. All photos do have proper users set as authors.
I will try debugging, maybe it reveals something.I had a chance to do another test. On my system, Contributors are not allowed to upload Media Library items. I was able to use the Media/Edit Media screen to set a contributor as the author of an image.
I added the
[mla_gallery?author="{+page_author+}"]
shortcode to a post authored by the contributor. The gallery it displays show only the one image with the proper author.If your testing reveals a different result, any further details you can provide will be helpful.
I tried again. If I change user form Contributor to Administator, nothing changes. It still shows all media on that user profile.. not filtered by user.
However, i did found this: if user has at least one post, then MLA shows photos properly. Only for users that have only photos but not posts, it shows all photos – not filtered by user.
[mla_gallery author="{+page_author+}" attachment_category='photographs' columns=4 orderby="date DESC" posts_per_page=24 size=thumbnail mla_caption='{+title+}<br>Фото: <a href="{+site_url+}/author/{+author:user_nicename+}">{+author+}/</a>' ] [mla_gallery author="{+page_author+}" attachment_category='photographs' posts_per_page=24 mla_output="paginate_links,prev_next"]
-
This reply was modified 1 year, 7 months ago by
pedjas.
Thanks for your continued testing and for your update. Clearly, my tests do not reproduce your application accurately.
How do you assign photos to users that do not have posts and users that cannot upload their own photos?
You wrote about the “user’s profile page” and the “user profile“. Can you tell me exactly how those are created and the URL used to access them? Where do the two shortcodes you included in your post show up? Do you have code in an “author” template page?
Thanks for your patience and any additional information you can provide.
In Admin/Users, for each user there is an option View. I click on it end get user page, which is referred as an Author page.
There is Author page template where I placed shortcodes.Thanks for confirming you use of a template file to hold the shortcodes.
It would be great if you could contact me at my web site and email me a copy of your template file. I want to reproduce your application as closely as possible. Thanks for your help!
I sent it.
Thanks for sending the template code you are using. I have been able to modify my own theme to reproduce and (I hope) fix the problem.
When the Author does not have any posts of their own, WordPress and/or the Theme code does not initialize the global
$post
object from which MLA retrieves thepage_author
value. Without that value the shortcodes ignore the emptyauthor="{+page_author+}"
parameter, displaying all photos withattachment_category='photographs'
.I have uploaded a new MLA Development Version dated 20230723 that generates an artificial “author post” object to handle this special case. You can find step-by-step instructions for using the Development Version in this earlier topic:
How to download & install the current development version of MLA
Once the Development Version is installed you can re-test the author pages without any posts. More information is available in the “Gallery-specific Substitution Parameters” subsection of the Settings/Media Library Assistant Documentation tab.
This update will be part of my next MLA version, but in the interim it would be great if you could install the Development Version and let me know if it works for you. Thanks for inspiring this MLA improvement.
Great! It works now! ??
Good job!
- The topic ‘Showing uploaded photos on user profile’ is closed to new replies.