mirjan cocka

27 Jul 2021

Add custom fields in user profile and display in Dashboard

Wordpress

Hello folks šŸ˜Š

Im struggling for a solution. My client wants that users can upload videos and pdf in they profile, when they register and those need to be displayed in a custom user dashboard. I'm working with elementor Pro and ACF.

Now I can add those fields, as file upload through ACF, problem is how to display them in Dashboard. I'm not expert in php, mabe this can be easy but I didn't find a solution. I want basicly video to be embed in dashboard, and a button to download pdf report.

 

Thanks in advance

Mirjan

Comments

Mohamed Atef

27 Jul 2021

githubgithubgithub

Hi Mirjan, I am admin Mohamed Atef & I am so happy to see you with us, to add this all you need to do is set the location of the custom fields group to 
ā€œUsers roleā€ like the screenshot below 
//prnt.sc/1grtn1s
and then you can edit the fields from the user profile like this screenshot

and that's all you need to control the fields from the dashboard 
let me know if you have any other questions 
Thanks

mirjan cocka

27 Jul 2021

Hello Mohamed, thanks for your reply. 

 

Yes I manage to do it and it works fine, my problem is displaying them In front end, in a custom user dashboard. So when a user will log, it redirects in this custom dashboard when he will have a video embedded to watch and a button to download pdf. I tryed elementor dynamic conditions, but no luck. 

Replies

Mohamed Atef

28 Jul 2021

githubgithubgithub

I got what you mean, when you add the fields and they appear link this inside the profile of the users (check this image)
you will need to display them using get_field() like the code below, this function will allow you to get the fields and show them with a shortcode called [showUserCustomFields], you can change the fields names to fit your fields

<?php 
	add_shortcode('showUserCustomFields', function(){
		$id = get_current_user_id();
		echo get_field('pdf', 'user_'.$id);
		echo "<br>";
		echo get_field('hello', 'user_'.$id);
	});
?>

I believe that the only trick is the in the second parameter of the get_field it should be like ā€˜user_1' 1 is the user id so you can get the dynamic user id using $id = get_current_user_id(); then add it to the function like the code 

Let me know if you get what i mean 
Good luck

Mohamed Atef

28 Jul 2021

githubgithubgithub

And please replay to my comment so I get a notification 

Replies

mirjan cocka

28 Jul 2021

thanks Mohamed.

it works

Mohamed Atef

28 Jul 2021

githubgithubgithub

you are so welcome :)

Ā© 2024 Copyrights reserved for web-brackets.com