We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Profile question required? | Forum

Topic location: Forum home » Support » General Questions
Marcus
Marcus Nov 19 '19

How to make the ow redirect to required question input after I set some question to required?


In other words I already had a question I set to to required but it does not redirect you to as I said above to required question input page why?


How to make this happen!


It does happen to new questions though!!!



This is my hack....



$questionsEditStamp = OW::getConfig()->getValue('base', 'profile_question_edit_stamp');   
   
   
BOL_PreferenceService::getInstance()->savePreferenceValue('profile_details_update_stamp', $questionsEditStamp, OW::getUser()->getId());

The Forum post is edited by Marcus Nov 19 '19
dave Leader
dave Nov 19 '19
I believe the reason is that it requires the user to log off and back on again before they get that "please complete this new field" page notice.   That could have something to do with the cron, maybe that function or class is only called on login by the cron.   Again i have never tested this but its good that you found it, if true i would call that a bug myself.   


But you also have to be careful with adding redirects.   What happens if you add a required field and the user is filling out a form or chatting and all of a sudden they get redirected right in the middle of a conversation or form submission to the required field page, that would upset most users.   Just be careful and test it fully.  :)

The Forum post is edited by dave Nov 19 '19
dave Leader
dave Nov 20 '19
After thinking about this more, i think the best solution is to have in your listener a site notify event so that when you add a new required profile field the user will get a site notification of this (or you can do an email if you want).  And in the site notification have a link to their profile just for convenience.    


I have not tested if they are asked to fill out the new field if they visit their profile or not (without logging out first).  If they do then the notication would be the best way IMO.  


This would keep any issues from arrising from the added redirect as it would no longer be needed.

Marcus
Marcus Nov 20 '19
Thanks Dave. It's its a bit messed up let me explain.

The question that was created prior to user registration will never ask to complete it despite the fact you just set it to required. 

On the other hand if you create new question after user register it will trigger complete profile redirect. 

The problem is in the statement that compares question creation datetime and profile update time. 

If question timestamp is more or equals to profile update timestamp trigger redirect... 

That's crazy what would they need that. 
dave Leader
dave Nov 21 '19
Thats how they checked which was newer, they compared the timestamps which are integer values to figure out if the question or the profile was newer.  If the question was newer then they wanted the user to complete it, if the profile was newer then do nothing because everything was updated already. 
Marcus
Marcus Nov 21 '19
That's ain't right case if I decide to switch some question to required it should be required for all what's the point of that it's beyond me.

Anyways what I do to trigger user with ID this profile complete is to change their update time to the question creation time. 

So I empty their question if it doesn't meet the guidelines then update their update time and in doing so it triggers complete profile on that particular user. 
The Forum post is edited by Marcus Nov 21 '19
dave Leader
dave Nov 21 '19

It would be required for all the next time they log in, i believe is how it works.



Im glad you got it working the way you want it to.  
Marcus
Marcus Nov 21 '19
Thanks Dave but it doesn't work like it suppose to work.

Go a head try it yourself. Update profile and leave some text question empty. Now set it to required log out, log back in again nothing happens. Lol

I have only one question is it save swaping user update timestamp for older one... It shouldn't precent any problems in my opinion but I'm kinda hesitant. 
The Forum post is edited by Marcus Nov 21 '19
dave Leader
dave Nov 22 '19
When i set mine to required and then go from the admin to the site, it brings up the question that i must compete.  But that might be your plugin doing that lol 
Marcus
Marcus Nov 22 '19
Yes that's the pluging it resets your last edit time to question edit time. 
Marcus
Marcus Nov 22 '19
Thanks Dave you rock buddy. Always there willing to help out. This community should be gratfull to have you around. 
dave Leader
dave Nov 22 '19
I thought so :)
dave Leader
dave Nov 22 '19
NP man, glad to help.... just pass the knowledge forward to someone else :0) have a look tomorrow at that code in the init file and let me know if thats good.  If you need help with next part (replacement) then ill check that out too, i remember you had asked about that but i wanted to get to know the plugin a bit first.. 
dave Leader
dave Nov 22 '19
Also remember it helps me too, i learn stuff as i go as well :)
Marcus
Marcus Nov 22 '19
Great appreciate it.