7

I've created a custom field (Checkboxes) in Wordpress > Users > Profile Fields. My site is an omni site for news, so it collects news from 20 different sources via RSS, and adds them ass posts in my Wordpress site. This is how my custom field looks like:

enter image description here

If you're only a visitor on my front page I'll show all posts on the startpage.

If you are a logged in user; then you should be able to select and save wich of the 20 sources you want to read in your startpage on my site. This is possible to select and save today, but only from BP User Settings page:

Select and Save sources from BP User Settings

Now, the issue with the Users Profile Settings page is:

a) I do not want to have the form in the tab "Profile > Edit". I want my form on my startpage (above the news flow, for logged on users of course) and perhaps in a widget sometime - anyhow - the most important this is freedom to place (and style) the form wherever I want.

b) The form includes fields I want to remove (Name and Description, i.e. "sources" = field name) etc.

The user on the image above has selected and saved to read news from 2 different sources on my website. The code that handles this is on the startpage in my index.php is:

$sources = xprofile_get_field_data( 'sources', $current_user_id, $multi_format = 'array' );
query_posts(array('category__and'=>array($sources)));

Question Is there a way of retrieving this form and update in from anywhere for logged in users? I don't want to be bound to the idea of only having the form in the Profile Settings page. I want the user to have to form above my news flow on the startpage of my site, so the users gets the feeling of "Oh, I can customize my news flow if I create an account!" - and this should be done from anywhere for logged in users.

Fernando Redondo
  • 1,557
  • 3
  • 20
  • 38
  • Since the edit xprofile functions work in a loop, it's probably easier to use custom queries to retrieve and save the data, especially in a single use case. And since you want it to run anywhere, you should write a plugin and use ajax for submit and save. – shanebp Aug 05 '15 at 15:04
  • Is this that difficult that it demads a own plugin? Feels like it should be easier, but then again, if that was the case I would probably have found an answer to this by now. How would your plugin look like? Not a PHP guy... – Fernando Redondo Aug 06 '15 at 07:45
  • You should add some more code showing how and where you generate and save the custom fields. – alpipego Aug 14 '15 at 06:14

1 Answers1

1

If I am getting it correctly, you want to display the form to logged in users. Have you tried

<?php if ( is_user_logged_in() ) { ... } ?>  function?

you may also wish to update user fields with

update_user_meta()

Spartacus
  • 1,468
  • 2
  • 15
  • 29
saq
  • 67
  • 6