Please or Register to create posts and topics.

Add check on forum access

Hi,

1/ My users can create and answer topics, and see pictures only when they are logged in (let’s say they get “Level 1” in this situation).
2/ Once they are logged in, they can subscribe for an upgrade, giving them more access to the rest of the site (so here they can access to “Level 2”. This upgrade is managed by another plugin : “Restrict Content Pro”. This other plugin has hooks and filters to fully custom access. Let’s say that access to Level 2 is called ‘rcp_access’.
3/ Today, my need is to update who can create and answer topics, and see pictures (1/) :
– When a user is logged out => he must receive the same messages than now (case above).
Update : When a user is logged in => he get a new message asking him to subscribe for ‘rcp_access’ (so just logging in is no more enough).
4/ Impacts :
– The only “front-end” indentified impacts (I think) are the existing messages asking to log in / register :
*in the header of the forum (with the yellow background)
*the message displayed when a user cannot see a picture (I changed the default label in .pot file to display a more engaging message asking to log in / register)
=> So both messages must be adapted to include the added check when a user is already logged in. It could be “Please, to do that, first you must get this access”.
5/ To do that :
– In the file forum.php (in  /wp-content/plugins/asgaros-forum/includes/), starting from line 589, it looks that we can make some custom allowing what I describe. If I’m right, could you please show me how to adapt this snippet ?
Maybe another file(s) are impacted ?
Thanks a lot for your help,
Best regards
Alcan

Hi @asgaros,

Let’s forget about the see pictures functionality. For that, I’ll let it work like now.

To resume :

  • A logged out user on the forum : Message* to Log in / Register displayed, cannot create / answer topics.
  • A logged in user on the forum not having ‘rcp_access’ : Message to upgrade to ‘rcp_access’ displayed, cannot create / answer topics (but can see pictures, and subscribe to topics, normal !)
  • A logged in user on the forum having ‘rcp_access’ : No message, can create / answer topics.

*The message is still the one with the yellow background box.

=> So the check is really about the create / answer topics functionnality. Maybe the 5/ part in my previous message is not complete enough.
In the same /forum.php, I see also :

Line 1569 :

if ((is_user_logged_in() && !$this->permissions->isBanned('current')) || (!is_user_logged_in() && $this->options['allow_guest_postings'])) {
// New topic button.

Line 1592 :

if ($this->approval->is_topic_approved($this->current_topic)) {
if ($this->permissions->can_create_post($current_user_id)) {
// Reply button.

 

Thanks,

Regards,
Alcan

Hi,

@asgaros Would you have any idea about that ?

Thank you,

regards,
Alcan

Hello @alcandau

I think a first step would be to call the add_notice(“your message”) function to add the required message to the upper area:

Currently there are no hooks available to modify the reply-functionality based on custom needs. So further code has to be added hard-coded to the plugin based on your custom permission-check.

Alcandau has reacted to this post.
Alcandau
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hi @asgaros

Thank you for your reply.

May you consider adding this hook to modify the reply-functionality based on custom needs (at least in your backlog) ?

At a shorter term, do you have any idea regarding the previous excerpt of code (around “create / answer topics” functionality) of what to hard-code more precisely ? If it is too complicated to explain here, I will understand.

Regards,
Alcan