F
F
freeman02042017-11-03 01:09:36
PHP
freeman0204, 2017-11-03 01:09:36

Sessions + ACF in WP, how?

The task is this:

when a user enters the site, he is shown 1 manager and he is assigned to him ... by ip or session, wherever he goes, there is one manager everywhere, managers are given in turn,

You also need the ability to add an infinite number of managers. This can be done through the ACF repeater. Let's say we have a repeater with the required fields and we have created 5 managers. We display them in the right place in the cycle.
But the bottom line is that you do not need to display everything at once, but in turn, for one user who has visited the site 1 manager. How to connect it, the output of the ACF repeater and the session, or can it determine a new person by IP address?
Found only how to enable sessions in WP.
add_action('init', 'omyblog_init_session', 1);
 
if ( !function_exists('omyblog_init_session')):
    function omyblog_init_session()
    {
        session_start();
    }
endif;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2017-11-03
@freeman0204

Store the number of the last manager issued in the option, put the manager's serial number in the cookie for the user and increase the value of the option by one, as soon as the number exceeds the total number of managers, reset it to zero and start over.
Before outputting the loop, get the user's cookie and output only the right one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question