uploads – if user role is x – show image – wordpress

Question

I have set up a member portal with ultimate member where users can fill in and submit various forms and then see the answers in a list. Each submitted answer is automatically converted into a pdf.

Each company has a unique role where they can only see the responses of their own role members. Test company has the role “testcompany”. There is also an admin for Test company who has the roles “testcompany” and “testcompany admin”.

I would like to create a shortcode that automatically retrieves the company logo (the role’s logo) and includes this in the form post and the pdf. Right now the user can upload a logo in the form, but it becomes unsustainable if he has to do this every time.

The best thing would be if you could make a page for each admin, where they can upload and change the company’s logo if necessary, but it would also work with a simpler version like:

You put all logos manually in the folder wp-content/userlogos/
Then you name them role names, for example:
testcompany.jpg
testcompany2.jpg
testcompany3.jpg

So if the user has the role testcompany2, the image testcompany2.jpg should be displayed.

Then you can just add a shortcode where you want to display the logo, and it will be downloaded automatically. Like [company_logo]

Should it be possible to add something to functions to make this work?

Found a bunch of switch codes, but that would mean the thread would be really long + I’d have to add new roles to the code, as soon as a new company joins the portal. There must be an easier way?

<?php $args = array( array('role' => 'administrator', 'img' => '<img src="http://placeape.com/100/100">'),array('role' => 'subscriber', 'img' => '<img src="http://placekitten.com/100/100">')); foreach ($args as $arg): userLooping($arg['role'], $arg['img']); endforeach; ?>

Is there anyone who can help me with this?

0
Masterior 1 month 2022-12-19T15:59:20-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse