Wordpress User Custom Field (Checkboxes) retrieve and update - from anywhere - php

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:
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:
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.

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()

Related

Display user profile field in frontend for manually created users by admin using ACF plugin

I am using a plugin that creates a shortcode for displaying user profile data in the frontend. I needed to add extra data which I made possible thanks to ACF plugin. I have been able to follow how-tos and the ACF fields now display in the frontend. This is where I am losing it.
When I view the page that displays the profile e.g example.com/profile/user, my code instead checks fields for the currently logged-in user instead of the user that I am looking at.
I cannot use get_the_author_meta() because I am manually creating the users so using that checks back for the author and instead of returning the original author it returns mine (which is how it's meant to work anyways).
Example of how I am fetching data
get_user_meta( $current_user->user_login, 'specialty', true )
specialty is the name of my custom field which I have added for user.
How can I fetch the intended username of the user I just created?
Thanks.

How to create a user page for wordpress?

In Wordpress there is an author.php template file that you can use to display author information. I am wondering if there is a way to create a template file to display a users information (any role), even if they are not an author to any post, but is a registered user.
By default, wordpress is handling profile page for authors only.
In your case, registered user seems any subscriber or editor also have profile page.
To handle that scenario you need to add plug-in.
User Profile Page
Ultimate Member

Joomla 3 Guests Redirect

So I have few articles in my menu which are for registered users only. I want them to be visible for everyone but if the user is not logged-in once he clicks on the menu I want him get redirected to the login page..
I saw this tutorial: Auto redirect guests to login but it seems outdated, in joomla 3.3 I can't find any "alias" menu item type.
Is there any alternative for that?
Iam using Joomla 3.3.1 with Community Builder.
-Thank you.
There are two ways you could do this really. One is through code and the other is through the administrators panel. I'm assuming based on the question you are interested in the back end solution.
This involves creating two unique menu items with the same name (alias' would need to be different). One which is only visible to logged in users, which points to the component view desired. The second menu is only visible to guests, and will point to the user log in component view with a redirect url set to component view you wish them to be redirected to.
I attached a link below to an article explaining how to only show menu items to guests and have them hide when users are logged in.
http://docs.joomla.org/How_do_you_hide_something_from_logged_in_users%3F

Search form controller

I am trying to create a Generic Search form (Controller) object. As in my website I have 4 different search forms, like
at Start Page I have a search form and on List page I have again a search form with more filters and on product page Have a search form with product specific property filters.
And what I want is that when user comes back from product page to list page, all the filters should a selected again automatically and if the user was on page 3 (pagination) the he should land again on page 3. Similarly from list to start, all the selected options should be populated again.
Is there any example available?
You could store this information in session variables.
For example, each time a list page is loaded, its number could be added to a $_SESSION["page_number"]; variable. Then whenever the list page loads again (being navigated from the product page for instance), the session value is used to retrieve the last viewed page. The form filters and other options could be stored in the same manner.

Wordpress Author Link 404

On a search page I allow the user to click a on the authors name to view all posts by that author. Im trying to create the link to the authors page but I keep getting 404’s. However the admin user works. I have checked the user types and they are set authors (Admin is administrator).
Code Example
get_author_posts_url(get_the_author_ID());
Result
This returns "/author/tester/" which looks correct since the admin one "/author/admin/" works. However clicking the link goes to 404.
Notes
This code is executed in a Wordpress loop.
User type is Author.
Ideally I would like to use the users nickname/display name not actual.
Try :
get_author_posts_url( $author->ID )
Also since you're using it within the loop, try without any ID :
get_author_posts_url()

Categories